mirror of
https://github.com/wassname/phaser.git
synced 2026-09-12 12:40:47 +08:00
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:
+10
-2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user