Jump to content

Can't start P2JS or NINJA


mraak
 Share

Recommended Posts

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

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

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

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

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

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

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

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.

Link to comment
Share on other sites

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

OMG that's right, somebody shimmed this one  :unsure:

 

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  :P
 
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.
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...