Skip to content

Instantly share code, notes, and snippets.

View ekelokorpi's full-sized avatar

Eemeli Kelokorpi ekelokorpi

View GitHub Profile
@ekelokorpi
ekelokorpi / data.json
Last active August 29, 2015 14:08
Core: Load JSON
{
"name": "Test"
}
@ekelokorpi
ekelokorpi / config.js
Created October 29, 2014 10:42
Config: Start scene
pandaConfig = {
system: {
startScene: 'Game'
}
};
@ekelokorpi
ekelokorpi / main.js
Created October 29, 2014 10:40
System: Change scene
// Change scene to Game
game.system.setScene('Game');
@ekelokorpi
ekelokorpi / main.js
Created October 29, 2014 10:39
Core: Create scene
// Create new scene named Main
game.createScene('Main', {
init: function() {
// Scene initiated
}
});
@ekelokorpi
ekelokorpi / config.js
Created October 25, 2014 08:44
Config: HiRes mode
// Example 1
pandaConfig = {
system: {
// HiRes mode with support for @2x textures
hires: 2
}
};
// Example 2
pandaConfig = {
@ekelokorpi
ekelokorpi / main.js
Created October 24, 2014 13:10
Pool: Basic usage
// Create new pool
game.pool.create('MyPool');
var myObject = {};
// Put object to pool
game.pool.put('MyPool', myObject);
// Get object from pool
var myObject2 = game.pool.get('MyPool');
@ekelokorpi
ekelokorpi / main.js
Created October 24, 2014 13:07
Keyboard: Basic usage
game.createScene('Main', {
keydown: function(key) {
if (key === 'SPACE') {
// Space key down
}
},
keyup: function(key) {
if (key === 'SPACE') {
// Space key up
@ekelokorpi
ekelokorpi / main.js
Created October 24, 2014 11:45
Camera: Basic usage
this.camera = new game.Camera();
this.camera.addTo(this.levelContainer);
this.camera.acceleration = 1.5;
this.camera.minX = this.camera.minY = 0;
this.camera.maxX = Math.max(0, this.level.width - game.system.width);
this.camera.maxY = Math.max(0, this.level.height - game.system.height);
this.camera.offset.x = game.system.width / 2 - 400;
this.camera.setPosition(this.player.sprite.position.x, this.player.sprite.position.y);
this.camera.follow(this.player.sprite);
@ekelokorpi
ekelokorpi / config.js
Last active August 29, 2015 14:08
Audio: Volume
// Define volume in config
pandaConfig = {
audio: {
soundVolume: 1.0,
musicVolume: 0.5
}
};
@ekelokorpi
ekelokorpi / main.js
Created October 24, 2014 11:40
Audio: Music
// Play music
game.audio.playMusic('music1');
// Change music
game.audio.playMusic('music2');
// Stop music
game.audio.stopMusic();