Bobcp Posted September 16, 2015 Share Posted September 16, 2015 Hello, i'm a newbie on js. I try to create a game on Phaser and use requirejs. I write this code'use strict';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, 'flappy-bird-reborn');// Game Statesgame.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 to fix that?Thank you Link to comment Share on other sites More sharing options...
drhayes Posted September 17, 2015 Share Posted September 17, 2015 In front of "new Phaser.Game(1334, 750, Phaser.AUTO, 'flappy-bird-reborn');" I think you're missing "var game = ". You don't have a variable named "game" right now. MichaelD and Bobcp 2 Link to comment Share on other sites More sharing options...
Recommended Posts