Last active
September 27, 2015 14:44
-
-
Save ada-lovecraft/9816091 to your computer and use it in GitHub Desktop.
Phaser 2.0 Tutorial: Flappy Bird (Part 1) : Full tutorial: http://codevinsky.ghost.io/phaser-2-0-tutorial-flappy-bird-part-1/
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
/* Full tutorial: http://codevinsky.ghost.io/phaser-2-0-tutorial-flappy-bird-part-1/ */ | |
'use strict'; | |
function Preload() { | |
this.asset = null; | |
this.ready = false; | |
} | |
Preload.prototype = { | |
preload: function() { | |
this.asset = this.add.sprite(this.width/2,this.height/2, 'preloader'); | |
this.asset.anchor.setTo(0.5, 0.5); | |
this.load.onLoadComplete.addOnce(this.onLoadComplete, this); | |
this.load.setPreloadSprite(this.asset); | |
this.load.image('background', 'assets/background.png'); | |
this.load.image('ground', 'assets/ground.png'); | |
this.load.image('title', 'assets/title.png'); | |
this.load.spritesheet('bird', 'assets/bird.png', 34,24,3); | |
this.load.image('startButton', 'assets/start-button.png'); | |
}, | |
create: function() { | |
this.asset.cropEnabled = false; | |
}, | |
update: function() { | |
if(!!this.ready) { | |
this.game.state.start('menu'); | |
} | |
}, | |
onLoadComplete: function() { | |
this.ready = true; | |
} | |
}; | |
module.exports = Preload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment