Skip to content

Commit e5a4620

Browse files
committed
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.
1 parent b94c78c commit e5a4620

6 files changed

Lines changed: 365 additions & 105 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ Significant API changes:
8787
* BitmapData has had all of the EaselJS functions removed. It was just taking up space and you can do it all via BitmapData.context directly.
8888
* BitmapText has had a bit of an overhaul - the signature for adding a BitmapText has changed to: x, y, font, text, size. See the docs and examples for details.
8989
* World preUpdate, update and postUpdate have all been moved to Stage. So all children are updated regardless where on the display list they live.
90+
* Cache.getImageKeys and similar has been removed, please use Cache.getKeys(Phaser.Cache.IMAGE) instead, this now supports all 10 Cache data types.
9091

9192

9293
New features:
@@ -112,6 +113,8 @@ New features:
112113
* Loader.bitmapFont now has 2 extra parameters: xSpacing and ySpacing. These allow you to add extra spacing to each letter or line of the font.
113114
* Added the new BitmapFont class. This is for rendering retro style fixed-width bitmap fonts into an Image object. It's a texture you can apply to a Sprite/Image.
114115
* Added Cache.updateFrameData which is really useful for swapping FrameData blocks in the cache.
116+
* Loader.physics now lets you load Lime + Corona JSON Physics data, which can be used with Body.loadPolygon and Body.loadData.
117+
* Cache.addPhysicsData and Cache.getPhysicsData allow you to store parsed JSON physics data in the cache, for sharing between Bodies.
115118

116119

117120
Updates:

examples/wip/p27.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload:
33

44
function preload() {
55

6-
// game.load.image('box', 'assets/sprites/block.png');
76
game.load.image('box', 'assets/sprites/diamond.png');
7+
game.load.physics('physobjects', 'assets/physics/diamond.json');
88

99
}
1010

@@ -24,8 +24,14 @@ function create() {
2424

2525
box.physicsEnabled = true;
2626

27+
box.body.clearShapes();
28+
29+
box.body.loadPolygon('physobjects', 'diamond');
30+
2731
box.body.rotateLeft(20);
2832

33+
// console.log(game.cache.getPhysicsData('physobjects', 'diamond'));
34+
2935
// 95x95
3036
// box.body.setRectangle(64, 64);
3137

@@ -41,7 +47,9 @@ function create() {
4147
// Works
4248
// box.body.addPolygon({}, -100, 100, -100, 0, 100, 0, 100, 100, 50, 50);
4349

44-
box.body.addPolygon({}, 32, 13 , 17, 28 , 15, 28 , 0, 13 , 0, 7 , 7, 0 , 25, 0 , 32, 7 );
50+
// box.body.addPolygon({}, -100, 100, -100, 0, 100, 0, 100, 100, 50, 50 );
51+
52+
// box.body.addPolygon({}, 32, 13 , 17, 28 , 15, 28 , 0, 13 , 0, 7 , 7, 0 , 25, 0 , 32, 7 );
4553

4654
// Works
4755
// box.body.setPolygon({}, -1, 1, -1, 0, 1, 0, 1, 1, 0.5, 0.5);

0 commit comments

Comments
 (0)