Cannot use the Physics Engine Box2D (quintus_physics.js) with canvas
Hi,
I'm triing to use the Physics Engine with canvas.
With SVG, it works well like in the "Device Orientation" project.
But in canvas, I have an error : TypeError: stage is undefined ../lib/quintus_physics.js Line 138
I tried to fix it in modifing this file but I failed.
Here is my code :
window.addEventListener('load',function(e) {
var Q = window.Q = Quintus().include("Sprites, Scenes, Touch, 2D, Physics");
Q.setup({ maximize: true }) .touch(Q.SPRITE_ALL);
Q.Sprite.extend("rectangle", { init: function(p) { this._super(p, { sheet: 'rect'});
//this.add("2d");
this.add("physics");
}
});
Q.scene("start",new Q.Scene(function(stage) {
stage.add("world");
stage.each(function() {
this.p.type = 'static';
this.add("physics");
});
stage.insert(new Q.rectangle({ x: 595, y: 100}));
stage.insert(new Q.rectangle({ x: 650, y: 500 }));
}
stage.insert(new Q.Sprite({ x: 5, y: 300, w: 10, h: 600 }));
stage.insert(new Q.Sprite({ x: 605, y: 300, w: 10, h: 600 }));
stage.insert(new Q.Sprite({ x: 200, y: 5, w: 800, h: 10 }));
stage.insert(new Q.Sprite({ x: 200, y: 595, w: 800, h: 10 }));
}));
Q.load("rectangle.png", function() { Q.sheet("rect","rectangle.png", { tilew: 84, tileh: 84 }); Q.stageScene("start"); });
});
By the way, really good job with this API, it will be useful ! Thank you, Maxime
Physics is pulled out of lib/ to extra/ in the latest release as it's not up to date with breaking changes - will take a look at it soon to merge back in.