Loader.physics now lets you load Lime + Corona JSON Physics data, which can be used with Body.loadPolygon and Body.loadData.

Cache.addPhysicsData and Cache.getPhysicsData allow you to store parsed JSON physics data in the cache, for sharing between Bodies.
This commit is contained in:
photonstorm
2014-02-14 23:51:49 +00:00
parent b94c78cf61
commit e5a4620b87
6 changed files with 365 additions and 105 deletions
+10 -2
View File
@@ -3,8 +3,8 @@ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:
function preload() {
// game.load.image('box', 'assets/sprites/block.png');
game.load.image('box', 'assets/sprites/diamond.png');
game.load.physics('physobjects', 'assets/physics/diamond.json');
}
@@ -24,8 +24,14 @@ function create() {
box.physicsEnabled = true;
box.body.clearShapes();
box.body.loadPolygon('physobjects', 'diamond');
box.body.rotateLeft(20);
// console.log(game.cache.getPhysicsData('physobjects', 'diamond'));
// 95x95
// box.body.setRectangle(64, 64);
@@ -41,7 +47,9 @@ function create() {
// Works
// box.body.addPolygon({}, -100, 100, -100, 0, 100, 0, 100, 100, 50, 50);
box.body.addPolygon({}, 32, 13 , 17, 28 , 15, 28 , 0, 13 , 0, 7 , 7, 0 , 25, 0 , 32, 7 );
// box.body.addPolygon({}, -100, 100, -100, 0, 100, 0, 100, 100, 50, 50 );
// box.body.addPolygon({}, 32, 13 , 17, 28 , 15, 28 , 0, 13 , 0, 7 , 7, 0 , 25, 0 , 32, 7 );
// Works
// box.body.setPolygon({}, -1, 1, -1, 0, 1, 0, 1, 1, 0.5, 0.5);