facetiousfactorial.cs Posted April 10, 2014 Share Posted April 10, 2014 For the past few days, I have been unable to get phaser to work: just trying to test a hello world program. I've followed the directions on phaser's site exactly, and it still isn't working for me.I am using node.js.Here is index.html: <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>Hello World</title> <style> #game_div { width: 500px; margin: auto; margin-top: 50px; } </style> <script type="text/javascript" src="phaser.min.js"></script> <script type="text/javascript" src="main.js"></script> </head> <body> <div id="game_div"> </div> </body> </html>Here is main.js: /*jslint node: true */ "use strict"; var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game_div'); var main_state = { preload: function () { game.load.image('hello', 'assets/hello.png'); }, create: function () { this.hello_sprite = game.add.sprite(200, 245, 'hello'); }, update: function () { this.hello_sprite.angle += 1; } } game.state.add('main', main_state); game.state.start('main');The error it gives me is: 'Phaser' was used before it was defined. var game = new Phaser.Game(400, 490, Phaser.AUTO, 'game_div');I've really tried looking for solutions to this, but I can't find anything wrong. I'm pretty new to javascript and phaser. Link to comment Share on other sites More sharing options...
plicatibu Posted April 11, 2014 Share Posted April 11, 2014 I copied your code verbatim and it worked like a charm. How are you starting the game? Simply opening the .HTML file in a browser may not work. Do you have an webserver (say Apache) running? facetiousfactorial.cs 1 Link to comment Share on other sites More sharing options...
shantanuaryan67 Posted April 3, 2016 Share Posted April 3, 2016 remove the "use strict" statement, it'll work fine Link to comment Share on other sites More sharing options...
drhayes Posted April 4, 2016 Share Posted April 4, 2016 That's your linter, it sounds like. Are you using something like jslint or jshint? Do you have some kind of build process? What editor are you using? Are you serving this through a web server? Link to comment Share on other sites More sharing options...
Recommended Posts