Created
February 18, 2016 08:57
-
-
Save AlexTiTanium/85a9bd0f58f9046275ab to your computer and use it in GitHub Desktop.
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 GameObject = require('GameObject'); | |
// Shortcuts | |
var game; | |
/** | |
* Player represent player objects | |
* | |
* @parent {GameObject} | |
* | |
* @constructor | |
*/ | |
var Player = function(gameLink, parent){ | |
GameObject.call(this, gameLink, parent); | |
game = this.game; | |
}; | |
/** | |
* Methods | |
*/ | |
Player.prototype = { | |
/** | |
* Preload is called first. Normally you'd use this to load your game assets (or those needed for the current State) | |
* You shouldn't create any objects in this method that require assets that you're also loading in this method, as | |
* they won't yet be available. | |
*/ | |
preload: function(){ | |
game.load.image('ship', 'assets/general/ship.png'); | |
}, | |
/** | |
* Create is called once preload has completed, this includes the loading of any assets from the Loader. | |
* If you don't have a preload method then create is the first method called in your State. | |
*/ | |
create: function(){ | |
game.add.sprite(300, 300 ,'ship'); | |
}, | |
/** | |
* It is called during the core game loop AFTER debug, physics, plugins and the Stage have had their preUpdate methods called. | |
* If is called BEFORE Stage, Tweens, Sounds, Input, Physics, Particles and Plugins have had their postUpdate methods called. | |
*/ | |
update: function(){ | |
//console.log('Update YEP YEP YEP'); | |
} | |
}; | |
// Extend | |
Player.prototype = _.extend(Player.prototype, GameObject.prototype); | |
// Export common js module | |
module.exports = Player; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment