ZRT Posted March 14, 2014 Share Posted March 14, 2014 Hey guys, First of all, thanks to all of those who made 2.0 happen. Keep up the good work! Now.. I'm trying to make states work but it seems that I'm missing something. I'm getting this error: Phaser.StateManager - No state found with the key: Boot I have some code sample here, might be a little ugly, I usually put every state in a different .js file Game = {};var width = 600;var height = 480;var game = new Phaser.Game(width, height, Phaser.AUTO,'');game.state.add('Boot', Game.Boot);game.state.add('Load', Game.Load);game.state.add('Play', Game.Play);game.state.add('Over', Game.Over);game.state.start('Boot');Game.Boot = function(game) {};Game.Boot.prototype = { preload: function() { label = game.add.text(width / 2 , height / 2, 'Loading...', { font: '20px Lucida Console', fill: '#FFFFFF' }); label.anchor.setTo(0.5, 0.5); game.load.image('player', 'assets/pl.png'); }, create: function() { game.state.start('Load'); }};Game.Load = function(game) {};Game.Load.prototype = { preload: function() { label = game.add.text(width / 2, height / 2, 'Click', { font: '20px Lucida Console', fill: '#FFF' }); label.anchor.setTo(0.5, 0.5); }, update: function() { if (game.input.activePointer.isDown) game.state.start('Play'); } };Game.Play = function(game) {};// Game.Play.prototype = {// };Thanks! Link to comment Share on other sites More sharing options...
Dream Of Sleeping Posted March 14, 2014 Share Posted March 14, 2014 I'm not 100% sure but try moving...game.state.add('Boot', Game.Boot);game.state.add('Load', Game.Load);game.state.add('Play', Game.Play);game.state.add('Over', Game.Over);game.state.start('Boot');to the bottom of the file. Link to comment Share on other sites More sharing options...
ZRT Posted March 14, 2014 Author Share Posted March 14, 2014 Yes, it works! I should've checked my other project before posting. The adding of the states is always below. Thanks. <script src="js/phaser.min-2.0.js"></script> <script src="js/load.js"></script> <script src="js/play.js"></script> <script src="js/config.js"></script> Link to comment Share on other sites More sharing options...
Recommended Posts