Jump to content

Phaser.StateManager - No state found with the key: boot


Recommended Posts

Hi guys, im creating a new project using:

$ yo phaser-official

My web server is an apache.


Im having this problem:

Phaser.StateManager - No state found with the key: boot 

What is wrong? I didnt changed the files, except the index.html, i did:



  <script src="js/phaser.js"></script>  <script src="js/game.js"></script>


  <script src="phaser.js"></script>  <script src="game/main.js"></script>
Link to comment
Share on other sites

Presumably somewhere in your code you're calling for the "boot" state with this:




without having defined a boot state, which would look like this:


game.state.add('boot', myGame.boot);


and should come before the first attempt to start the boot state. Note that "myGame.boot" refers to a function, which you'll need to provide yourself, and can be called anything. I just called it "myGame.boot" as an example. This function will contain the code of the boot state.

Link to comment
Share on other sites

  • 2 years later...

I have a question regarding this issue. I am getting the same error.  Any help would be appreciated.  I wanted to use an object to contain the game, so maybe that is the issue.  I define the  object, RunRun, on the index.html page.  I define it within the script tag.

Here is what I am using for the index.html page:


  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="mobile-web-app-capable" content="yes">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <title>Phaser Basic Project Template</title>
  <script type="text/javascript" src="js/phaser.js"></script>
  <script type="text/javascript" src="js/Boot.js"></script>
  <script type="text/javascript" src="js/Preloader.js"></script>
  <script type="text/javascript" src="js/MainMenu.js"></script>
  <script type="text/javascript" src="js/Game.js"></script>


  <div id="gameContainer"></div>

  <script type="text/javascript">
    window.onload = function() {

      //	Create your Phaser game and inject it into the gameContainer div.
      //	We did it in a window.onload event, but you can do it anywhere (requireJS load, anonymous function, jQuery dom ready, - whatever floats your boat)
      var RunRun = RunRun || {};
      RunRun.game = new Phaser.Game(1024, 768, Phaser.CANVAS, 'gameContainer');

      //	Add the States your game has.
      //	You don't have to do this in the html, it could be done in your Boot state too, but for simplicity I'll keep it here.
      RunRun.game.state.add('Boot', RunRun.Boot);
      RunRun.game.state.add('Preloader', RunRun.Preloader);
      RunRun.game.state.add('MainMenu', RunRun.MainMenu);
      RunRun.game.state.add('Game', RunRun.Game);

      //	Now start the Boot state.




And here is the Boot.js file:


var RunRun = RunRun || {};

RunRun.Boot = function() {};

console.log("hello world!!!!!!!!!");

RunRun.Boot.prototype = {

  init: function() {

    //  Unless you specifically know your game needs to support multi-touch I would recommend setting this to 1
    this.input.maxPointers = 1;

    //  Phaser will automatically pause if the browser tab the game is in loses focus. You can disable that here:
    this.stage.disableVisibilityChange = true;

    if (this.RunRun.device.desktop) {
      //  If you have any desktop specific settings, they can go in here
      this.scale.pageAlignHorizontally = true;
    } else {
      //  Same goes for mobile settings.
      //  In this case we're saying "scale the game, no lower than 480x260 and no higher than 1024x768"
      this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
      this.scale.setMinMax(480, 260, 1024, 768);
      this.scale.forceLandscape = true;
      this.scale.pageAlignHorizontally = true;


  preload: function() {

    //  Here we load the assets required for our preloader (in this case a background and a loading bar)
    this.load.image('preloaderBackground', 'assets/images/testLogo.png');
    this.load.image('preloaderBar', 'assets/images/preloadr-bar.png');


  create: function() {

    //  By this point the preloader assets have loaded to the cache, we've set the game settings
    //  So now let's start the real preloader going




Link to comment
Share on other sites

The error message is -> Phaser.StateManager - No state found with the key: Boot

Please note, the index.html file is in the root folder of the project.  The Boot.js file is in the js subdirectory.


I have been doing some experiments, and if I remove the line var RunRun = RunRun || {};   from the index.html file

then everything loads, the Phaser.StateManager finds the Boot key and everything starts to load.  Any idea why?

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...