Page 1 of 1

Phaser 2.4.8 and 2.4.7 rube-loader not working

Posted: Fri May 20, 2016 3:18 pm
by sheik
I believe the "rube-loader-for-phaser-box2d-plugin" is in need of a small update.
I think it's just a namespace issue, but I don't know how to fix the issue.

I receive the following error (see attached screenshot)
Screen Shot 2016-05-20 at 11.12.58 AM.png
Screen Shot 2016-05-20 at 11.12.58 AM.png (106.53 KiB) Viewed 22152 times
I am using Intel XDK.
This is the order that I am loading the libraries.

Code: Select all

    
<script src="lib/phaser.min.js"></script>
<script src="lib/box2d-plugin-full.js"></script>
<script src="lib/phaser-rube.js"></script>
<script src="src/Game.js"></script>
<script src="src/app.js"></script>
This is the example 'create'' function that I am using.

Code: Select all

    create: function () {
        this.physics.startSystem(Phaser.Physics.BOX2D);
        this.physics.box2d.setPTMRatio(20);

        levelScene = new Phaser.Physics.Box2D.RubeScene('level');
        levelScene.load();

        this.camera.bounds.setTo(-10000, -10000, 20000, 20000);
        this.camera.x = -400;
        this.camera.y = -300;

        this.input.onDown.add(mouseDragStart, this);
        this.input.addMoveCallback(mouseDragMove, this);
        this.input.onUp.add(mouseDragEnd, this);
    },

Re: Phaser 2.4.8 and 2.4.7 rube-loader not working

Posted: Fri May 20, 2016 11:33 pm
by iforce2d
Perhaps you could check the release notes for the new Phaser version, if they're going to break backward compatibility like this there should be a mention of the change and how to deal with it.

Re: Phaser 2.4.8 and 2.4.7 rube-loader not working

Posted: Sun May 22, 2016 4:55 am
by sheik
iforce2d wrote:Perhaps you could check the release notes for the new Phaser version, if they're going to break backward compatibility like this there should be a mention of the change and how to deal with it.
I did as you suggested, but I couldn't find anything promising. https://github.com/photonstorm/phaser/releases

I have a basic understanding of javascript, but I think my issue is because I'm using Phaser States.
When using states, instead of using 'game' you use 'this'. (There's a state manager guide in the Phaser Mega Bundle).

So I am calling this rube-loader function like this:

Code: Select all

this.physics.box2d.setPTMRatio(20);
instead of the usual

Code: Select all

game.physics.box2d.setPTMRatio(20);
Function definition for reference

Code: Select all

// If the PTM ratio is changed after creating the world, the debug draw scale needs to be updated
Phaser.Physics.Box2D.prototype.setPTMRatio = function(newRatio) {
    this.ptmRatio = newRatio;
    game.physics.box2d.debugDraw = new Phaser.Physics.Box2D.DefaultDebugDraw(this.ptmRatio);
    game.physics.box2d.world.SetDebugDraw( game.physics.box2d.debugDraw );
}
Right now, I believe changes will need to be made to support states. My javascript knowledge is fairly basic though. Thank you for your help!