Skip to content

Instantly share code, notes, and snippets.

View ekelokorpi's full-sized avatar

Eemeli Kelokorpi ekelokorpi

View GitHub Profile
game.module(
'game.main'
)
.body(function() {
game.createScene('Main', {
init: function() {
var sprite = new game.Sprite('panda.png');
sprite.addTo(this.stage);
}
@ekelokorpi
ekelokorpi / main.js
Created November 11, 2014 08:32
Video: Basic usage
var video = new game.Video('video.mp4');
video.sprite.anchor.set(0.5, 0.5);
video.sprite.position.set(game.system.width / 2, game.system.height / 2);
video.sprite.addTo(this.stage);
video.onLoaded(function() {
// Video loaded
});
video.onComplete(function() {
@ekelokorpi
ekelokorpi / main.js
Created November 7, 2014 08:25
System: Pause/resume
game.system.pause(); // Pause game engine
game.system.resume(); // Resume game engine
@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