smdool Posted September 13, 2015 Share Posted September 13, 2015 I am looking to extend the Phaser tutorial "Making your first Phaser game" (http://phaser.io/tutorials/making-your-first-phaser-game) by introducing states as described in this post "Understanding Phaser states" (http://www.emanueleferonato.com/2014/08/28/phaser-tutorial-understanding-phaser-states/) The Update function in my play.js provides an overlap callback to a custom function called gameOver (line 161). It is at this point on line 179 whereby this.game, and hence 'state', is undefined as 'this' is now referring to the custom function. The tutorial 'understanding Phaser states' references this.game inside custom functions yet doesn't error. Hoping someone could point myself in the right direction in resolving this issue. The code can be viewed on Github https://github.com/smdooley/PhaserDemo/blob/master/tutorial-03/play.js Link to comment Share on other sites More sharing options...
tips4design Posted September 13, 2015 Share Posted September 13, 2015 First of all, this does nothing: var play = function(game) { console.log('play'); var platforms; var player; var baddies; var cursors; var stars; var score; var scoreText; }; Creating local variables or passing the game parameter to that function only creates those variables inside that function scope and are deleted afterwards. That is the same as doingvar play = function() { console.log('play'); } Link to comment Share on other sites More sharing options...
Recommended Posts