stuartabowler Posted March 16, 2014 Share Posted March 16, 2014 Hi there, I'm trying to get off the ground with creating my own phaser games, but I've hit a blocker that I just can't work out. I have a very basic setup, based on the Phaser Tutorial examples:index.htmljsphaser.min.jsassetsstarfield.pngThis is my very, very basic index.html code - but it falls over at the first hurdle when I try to access a game.physics method:<!doctype html><html> <head> <meta charset="UTF-8" /> <title>hello phaser!</title> <script type="text/javascript" src="js/phaser.min.js"></script> </head> <body> <script type="text/javascript"> window.onload = function() { var game = new Phaser.Game(1900, 1000, Phaser.AUTO, '', { preload: preload, create: create }); function preload () { game.load.image('starfield', 'assets/starfield.png'); } function create () { game.physics.startSystem(Phaser.Physics.ARCADE); // The scrolling starfield background starfield = game.add.tileSprite(0, 0, 1900, 1000, 'starfield'); } }; </script> </body></html>In Chrome I get the following error: Uncaught TypeError: Object #<Object> has no method 'enable' (index):48 create(index):48 d.StateManager.loadCompletephaser.min.js:4 d.Game.loadCompletephaser.min.js:5 d.SignalBinding.executephaser.min.js:4 d.Signal.dispatchphaser.min.js:4 dispatchphaser.min.js:4 d.Loader.nextFilephaser.min.js:10 d.Loader.fileCompletephaser.min.js:9 a.data.onloadphaser.min.js:9 This is all running locally under Apache. I have tried a few other basic things, but whenever I try to access any Phaser object methods I get this same 'Uncaught TypeError' issue. I have phaser-examples set up locally, and these run just fine - as do the Phaser Tutorial examples. I have been trying to just build out from the tutorials to experiment and get to grips with everything. I assume it's a really dumb error, but I just can't see where I'm going wrong. Any tips would be gratefully accepted. Thanks,Stu Link to comment Share on other sites More sharing options...
rich Posted March 16, 2014 Share Posted March 16, 2014 I can't see anything wrong with the above, so it has to be something related to the version of phaser you're using. Where did you get the phaser.min.js file from? Link to comment Share on other sites More sharing options...
stuartabowler Posted March 17, 2014 Author Share Posted March 17, 2014 I cloned Phaser from Github. You're absolutely right, though - somehow I had v1.1.3 instead of v2 in my test game. I must have picked it up from one of the examples I was toying with. Switching to v2 has fixed everything - we have physics! Thank you. Out of interest, I have seen comments suggesting using Gruntfile.js to build from - but I'm not clear what to do with that. Run `grunt` to perform a default build to the `dist` folder and update the examples. Is it just a case of loading this file in a browser? Link to comment Share on other sites More sharing options...
prtksxna Posted March 17, 2014 Share Posted March 17, 2014 Try to use the already minified file in the repository. Link to comment Share on other sites More sharing options...
Recommended Posts