This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Play sound | |
var jumpSound = game.audio.playSound('jump'); | |
// Pause sound | |
game.audio.pauseSound(jumpSound); | |
// Resume sound | |
game.audio.resumeSound(jumpSound); | |
// Pause all playing sounds |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add audio to load queue and give it id 'jump' | |
game.addAudio('jump.m4a', 'jump'); | |
// Play sound | |
var jumpSound = game.audio.playSound('jump'); | |
// Stop sound | |
game.audio.stopSound(jumpSound); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create animation with 3 frames | |
var anim = new game.Animation('frame1.png', 'frame2.png', 'frame3.png'); | |
// Set animation speed | |
anim.animationSpeed = 0.2; | |
// Play animation | |
anim.play(); | |
// Add animation to stage | |
anim.addTo(game.scene.stage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sprite = new game.TilingSprite('sprite.png', 1000, 1000); | |
// Set speed for TilingSprite | |
sprite.speed.set(50, 100); | |
sprite.addTo(game.scene.stage); | |
// Use addObject method, so TilingSprite will get updated | |
game.scene.addObject(sprite); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create TilingSprite with size of 1000x1000 | |
var sprite = new game.TilingSprite('sprite.png', 1000, 1000); | |
sprite.addTo(game.scene.stage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text = new game.BitmapText('Hello', { font: 'MyFont' }); | |
text.setText('New text'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text = new game.BitmapText('Hello', { font: 'MyFont' }); | |
text.position.set(100, 100); | |
text.addTo(this.stage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Creates spritesheet with frame size 138x100 | |
var spritesheet = new game.SpriteSheet('spritesheet.png', 138, 100); | |
// Returns sprite using frame 0 from spritesheet | |
var sprite = spritesheet.frame(0); | |
sprite.addTo(this.stage); | |
// Returns 15 frames long animation, starting from frame 2 | |
var anim = spritesheet.anim(15, 2); | |
anim.animationSpeed = 0.3; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create physics world | |
this.world = new game.World(); | |
// Create new body | |
var body = new game.Body(); | |
// Set body position | |
body.position.x = 200; | |
body.position.y = 200; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text = new game.BitmapText('HELLO', { font: 'MyFont' }); | |
text.cacheAsBitmap = true; | |
var emitter = new game.Emitter(); | |
// Use cached sprite from BitmapText as particle texture | |
emitter.textures.push(text._cachedSprite.texture); |