Phaser 2.4.8 and 2.4.7 rube-loader not working

Report problems here (or use the built-in feedback dialog in the editor)
Post Reply
sheik
Posts: 3
Joined: Wed May 18, 2016 6:05 pm

Phaser 2.4.8 and 2.4.7 rube-loader not working

Post 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 22137 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);
    },
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Phaser 2.4.8 and 2.4.7 rube-loader not working

Post 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.
sheik
Posts: 3
Joined: Wed May 18, 2016 6:05 pm

Re: Phaser 2.4.8 and 2.4.7 rube-loader not working

Post 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!
Post Reply