mirror of
https://github.com/photonstorm/phaser
synced 2024-11-13 00:17:24 +00:00
P2.Body.loadPolygon now allows the key
parameter to be passed as null
- when this happens the object
parameter can be the actual physics object data instead of a string pointing to the cache, allowing you to take advantage of adding multiple convex shapes with automatic adjustments for center of mass #1801
This commit is contained in:
parent
cf83f51315
commit
17831e0103
2 changed files with 19 additions and 3 deletions
|
@ -309,6 +309,7 @@ Version 2.4 - "Katar" - in dev
|
|||
* Rectangle.random will return a uniformly distributed random point from anywhere within the rectangle.
|
||||
* Line.rotate allows you to rotate a line by the given amount around its center point.
|
||||
* Device.chromeVersion will return the major version number of Chrome.
|
||||
* TilingSprite.textureDebug is a new boolean that allows you to visually debug the generated texture a TilingSprite creates.
|
||||
|
||||
### Updates
|
||||
|
||||
|
@ -348,6 +349,7 @@ Version 2.4 - "Katar" - in dev
|
|||
* ScaleManager.scaleSprite will no longer try and scale a display object that doesn't have a scale property.
|
||||
* The LoadTexture component has a new property `customRender` which is checked for in the Core postUpdate to know when to render custom elements like Videos.
|
||||
* BitmapText line spacing and word wrapping has been vastly improved and bought in-line with how Pixi 3 handles it, but with additional anchor support.
|
||||
* P2.Body.loadPolygon now allows the `key` parameter to be passed as `null` - when this happens the `object` parameter can be the actual physics object data instead of a string pointing to the cache, allowing you to take advantage of adding multiple convex shapes with automatic adjustments for center of mass #1801
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -1253,15 +1253,29 @@ Phaser.Physics.P2.Body.prototype = {
|
|||
|
||||
/**
|
||||
* Reads the shape data from a physics data file stored in the Game.Cache and adds it as a polygon to this Body.
|
||||
*
|
||||
* As well as reading the data from the Cache you can also pass `null` as the first argument and a
|
||||
* physics data object as the second. When doing this you must ensure the structure of the object is correct in advance.
|
||||
*
|
||||
* For more details see the format of the Lime / Corona Physics Editor export.
|
||||
*
|
||||
* @method Phaser.Physics.P2.Body#loadPolygon
|
||||
* @param {string} key - The key of the Physics Data file as stored in Game.Cache.
|
||||
* @param {string} object - The key of the object within the Physics data file that you wish to load the shape data from.
|
||||
* @param {string} key - The key of the Physics Data file as stored in Game.Cache. Alternatively set to `null` and pass the
|
||||
* data as the 2nd argument.
|
||||
* @param {string|object} object - The key of the object within the Physics data file that you wish to load the shape data from,
|
||||
* or if key is null pass the actual physics data object itself as this parameter.
|
||||
* @return {boolean} True on success, else false.
|
||||
*/
|
||||
loadPolygon: function (key, object) {
|
||||
|
||||
var data = this.game.cache.getPhysicsData(key, object);
|
||||
if (key === null)
|
||||
{
|
||||
var data = object;
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = this.game.cache.getPhysicsData(key, object);
|
||||
}
|
||||
|
||||
// We've multiple Convex shapes, they should be CCW automatically
|
||||
var cm = p2.vec2.create();
|
||||
|
|
Loading…
Reference in a new issue