0

I'm creating my first game with Phaser and am using requirejs.

I wrote this code:

requirejs.config({
  baseUrl: 'game',
  paths: {
    Phaser: 'js/phaser.min',
    BootState: 'states/boot',
    MenuState: 'states/menu',
    PreloadState: 'states/preload',
  }
});

var BootState = require(['Phaser']);
var MenuState = require(['MenuState']);
var PreloadState = require(['PreloadState']);

new Phaser.Game(1334, 750, Phaser.AUTO, 'bird-reborn');

// Game States

game.state.add('boot', BootState);
game.state.add('menu', MenuState);
game.state.add('play', PlayState);
game.state.add('preload', PreloadState);

game.state.start('boot');

And have this error Uncaught ReferenceError: game is not defined

How do I fix this? Thank you!

1 Answer 1

1

Replace this line :

new Phaser.Game(1334, 750, Phaser.AUTO, 'bird-reborn');

By this :

var game = new Phaser.Game(1334, 750, Phaser.AUTO, 'bird-reborn');
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.