mraak Posted April 25, 2014 Share Posted April 25, 2014 game.physics.startSystem(Phaser.Physics.P2JS); I can load the ARCADE but both NINJA and P2JS are producing an error in the console. Uncaught TypeError: undefined is not a function Link to comment Share on other sites More sharing options...
rich Posted April 25, 2014 Share Posted April 25, 2014 Needless to say, are you using the version of Phaser that has them all bundled in? Heppell08 1 Link to comment Share on other sites More sharing options...
mraak Posted April 25, 2014 Author Share Posted April 25, 2014 My bower says this "phaser-official": "2.0.3" That means that all physics examples are broken that are published on examples.phaser.io? I still found this in the source I'm using: /** * This will create an instance of the requested physics simulation. * Phaser.Physics.Arcade is running by default, but all others need activating directly. * You can start the following physics systems: * Phaser.Physics.P2JS - A full-body advanced physics system by Stefan Hedman. * Phaser.Physics.NINJA - A port of Metanet Softwares N+ physics system. * Phaser.Physics.BOX2D and Phaser.Physics.CHIPMUNK are still in development. * * @method Phaser.Physics#startSystem * @param {number} The physics system to start. */ startSystem: function (system) { if (system === Phaser.Physics.ARCADE) { this.arcade = new Phaser.Physics.Arcade(this.game); } else if (system === Phaser.Physics.P2JS) { this.p2 = new Phaser.Physics.P2(this.game, this.config); } if (system === Phaser.Physics.NINJA) { this.ninja = new Phaser.Physics.Ninja(this.game); } else if (system === Phaser.Physics.BOX2D && this.box2d === null) { throw new Error('The Box2D physics system has not been implemented yet.'); } else if (system === Phaser.Physics.CHIPMUNK && this.chipmunk === null) { throw new Error('The Chipmunk physics system has not been implemented yet.'); } }, Link to comment Share on other sites More sharing options...
jpdev Posted April 25, 2014 Share Posted April 25, 2014 For me the examples all work. Do they not work in your browser? - Or does the code not work if you copy it into your own project?(Then there is clearly something wrong with the project.. if they work in your browser on the page) Link to comment Share on other sites More sharing options...
mraak Posted April 26, 2014 Author Share Posted April 26, 2014 No, they don't work locally because these lines always fail. But they work on the Phaser website of course as maybe those are using different version of Phaser. As I said, I use 2.0.3 and these two lines always fail. game.physics.startSystem(Phaser.Physics.P2JS); or game.physics.startSystem(Phaser.Physics.NINJA); Link to comment Share on other sites More sharing options...
rich Posted April 26, 2014 Share Posted April 26, 2014 The Phaser site is using 2.0.3, and trust me if none of the physics systems started up at all then you'd see hundreds of similar forum posts here! What's the actual error you get? (it appears truncated in your first post), and post the whole code up, not just the one single line. Also you're definitely serving these via a local httpd or similar, yes? Link to comment Share on other sites More sharing options...
Heppell08 Posted April 26, 2014 Share Posted April 26, 2014 Is it not something to do with the examples being now seperate to the phaser source itself and have since not been updated by @mraakTotal hunch but since that was a new thing for phaser, might be a possibility? Link to comment Share on other sites More sharing options...
rich Posted April 26, 2014 Share Posted April 26, 2014 Possibly - could just download the JS file from github instead of bower. I still reckon it's the wrong version up there. Heppell08 1 Link to comment Share on other sites More sharing options...
mraak Posted April 26, 2014 Author Share Posted April 26, 2014 I'm running locally through Gulp so yes it's on localhost. Using bower with the version I specified. ARCADE works and I'm using it in bunch of games, but the other two fail. This is all the code I have: var _ = require("underscore"), Phaser = require("phaser");var game = new Phaser.Game(500, 330, Phaser.AUTO, "game", {preload: function(){},create: function(){ game.physics.startSystem(Phaser.Physics.P2JS);},render: function(){},update: function(){}});{ "name": "base", "version": "0.0.1", "private": true, "ignore": [ "**/.*", "libs", "node_modules" ], "dependencies": { "phaser-official": "2.0.3" }} Link to comment Share on other sites More sharing options...
Heppell08 Posted April 26, 2014 Share Posted April 26, 2014 Start phaser, get the error and post a full screenshot of the console error.Phaser has no issues loading any of the physics based systems so it really is something (probably quite simple) on your behalf mraak.Whenever phaser starts and you load it in a web browser it will also throw a console log telling you version, webgl etc etc. What version does that console log say?Also, how are you setting the files up? Do you have 'states'? A single file? Is your index properly told the that phaser is in place via script tags?All these small steps are a means to getting some answers on this. Link to comment Share on other sites More sharing options...
mraak Posted April 26, 2014 Author Share Posted April 26, 2014 Phaser v2.0.3 - WebGL - WebAudio http://phaser.io Lol, image inserting not working with Dropbox URL, and there's no way to upload an image from desktop. Here's a link. https://www.dropbox.com/s/lku1e7szw5av0o2/Screenshot%202014-04-26%2000.46.59.png No, I'm not using states, and everything else in Phaser works like a charm. As I said there is many, over 5 games in progress on the same setup, everywhere there's the same symptom. Link to comment Share on other sites More sharing options...
Heppell08 Posted April 26, 2014 Share Posted April 26, 2014 Did you rename the phaser file your? Is it the same name in the index script tags?If all else fails just get the raw phaser.js and use that instead:-https://github.com/photonstorm/phaser/tree/master/build Link to comment Share on other sites More sharing options...
george Posted April 26, 2014 Share Posted April 26, 2014 I can see you're loading the file 'phaser-arcade-physics'That brings us back to the first reply from Rich. Needless to say, are you using the version of Phaser that has them all bundled in? phaser-arcade-physics.js stands for Phaser with arcade physics bundled. There is no P2 or Ninja included. And that's no bug, it's a feature to reduce the file size for all the people who only want to use the arcade physics. I don't say that you should be embarrassed with this question- but the next time a little bit of thinking about what files you are actually including could help Now have fun with phaser physics. Heppell08 1 Link to comment Share on other sites More sharing options...
Heppell08 Posted April 26, 2014 Share Posted April 26, 2014 I can see you're loading the file 'phaser-arcade-physics'That brings us back to the first reply from Rich. phaser-arcade-physics.js stands for Phaser with arcade physics bundled. There is no P2 or Ninja included. And that's no bug, it's a feature to reduce the file size for all the people who only want to use the arcade physics. I don't say that you should be embarrassed with this question- but the next time a little bit of thinking about what files you are actually including could help Now have fun with phaser physics. I had a feeling that file was too different. I've never used any of them smaller bundled files but was most certainly something that was causing it. Note: Keep it SIMPLE and use the main phaser js file until you know fully what parts you do or dont need for projects and use accordingly.Have fun Link to comment Share on other sites More sharing options...
mraak Posted April 26, 2014 Author Share Posted April 26, 2014 OMG that's right, somebody shimmed this one shim: { phaser: { path: "libs/phaser-official/build/custom/phaser-arcade-physics.min.js", exports: "Phaser" }, I wasn't aware of the file structure of Phaser builds so at least I learned that. Glad this is solved and sorry to waste your precious time A bit of explanation, I noticed the file had an "arcade" in the name, but I thought that's maybe one of the included pieces, didn't know that's the whole release with just with no other physics in it but arcade. My mistake for not reading what's packed in each file before using it, that's said, I haven't stumbled across that piece of info. george 1 Link to comment Share on other sites More sharing options...
Recommended Posts