mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
Body setSize changes to fix #3863 PR
This commit is contained in:
parent
872a7c792f
commit
3d23013b86
3 changed files with 31 additions and 13 deletions
|
@ -57,6 +57,7 @@ The process of managing scissors in the WebGLRenderer has been completely rewrit
|
|||
* The `setBlendMode` method in the WebGL Renderer now returns a boolean. True if a new blend mode was set, otherwise false. Previously in returned a reference to the renderer instance.
|
||||
* The `load.html` method has been renamed to `load.htmlTexture`.
|
||||
* The method `batchVertices` in the TextureTintPipeline has been renamed to `batchQuad` which more accurately describes what it does.
|
||||
* In ArcadePhysics `Body.setSize` you can now choose to not pass width and height values to the method. If you do this it will check to see if the parent Game Object has a texture frame, and if so, it will use the frame sizes for the Body dimensions (thanks @tarsupin)
|
||||
|
||||
### Game Config Resolution Specific Bug Fixes
|
||||
|
||||
|
|
|
@ -1071,14 +1071,14 @@ var Body = new Class({
|
|||
|
||||
/**
|
||||
* Sizes and positions this Body's boundary, as a rectangle.
|
||||
* Modifies the Body's `offset` if `center` is true (the default).
|
||||
* Resets the width and height to match current frame, if no width and height provided.
|
||||
* Modifies the Body `offset` if `center` is true (the default).
|
||||
* Resets the width and height to match current frame, if no width and height provided and a frame is found.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.Body#setSize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} width - The width of the Body, in source pixels.
|
||||
* @param {number} height - The height of the Body, in source pixels.
|
||||
* @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width.
|
||||
* @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height.
|
||||
* @param {boolean} [center=true] - Modify the Body's `offset`, placing the Body's center on its Game Object's center.
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.Body} This Body object.
|
||||
|
@ -1089,8 +1089,15 @@ var Body = new Class({
|
|||
|
||||
var gameObject = this.gameObject;
|
||||
|
||||
if (width === undefined) { width = gameObject.frame.data.sourceSize.w; }
|
||||
if (height === undefined) { height = gameObject.frame.data.sourceSize.h; }
|
||||
if (!width && gameObject.frame)
|
||||
{
|
||||
width = gameObject.frame.realWidth;
|
||||
}
|
||||
|
||||
if (!height && gameObject.frame)
|
||||
{
|
||||
height = gameObject.frame.realHeight;
|
||||
}
|
||||
|
||||
this.sourceWidth = width;
|
||||
this.sourceHeight = height;
|
||||
|
|
|
@ -487,25 +487,35 @@ var StaticBody = new Class({
|
|||
|
||||
/**
|
||||
* Sets the size of the body.
|
||||
* Resets the body to match the current frame if no width or height is provided.
|
||||
* Resets the width and height to match current frame, if no width and height provided and a frame is found.
|
||||
*
|
||||
* @method Phaser.Physics.Arcade.StaticBody#setSize
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} width - [description]
|
||||
* @param {number} height - [description]
|
||||
* @param {number} [offsetX] - [description]
|
||||
* @param {number} [offsetY] - [description]
|
||||
* @param {integer} [width] - The width of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame width.
|
||||
* @param {integer} [height] - The height of the Body in pixels. Cannot be zero. If not given, and the parent Game Object has a frame, it will use the frame height.
|
||||
* @param {number} [offsetX] - The horizontal offset of the Body from the Game Object's center.
|
||||
* @param {number} [offsetY] - The vertical offset of the Body from the Game Object's center.
|
||||
*
|
||||
* @return {Phaser.Physics.Arcade.StaticBody} This Static Body object.
|
||||
*/
|
||||
setSize: function (width, height, offsetX, offsetY)
|
||||
{
|
||||
if (width === undefined) { width = this.gameObject.frame.data.sourceSize.w; }
|
||||
if (height === undefined) { height = this.gameObject.frame.data.sourceSize.h; }
|
||||
if (offsetX === undefined) { offsetX = this.offset.x; }
|
||||
if (offsetY === undefined) { offsetY = this.offset.y; }
|
||||
|
||||
var gameObject = this.gameObject;
|
||||
|
||||
if (!width && gameObject.frame)
|
||||
{
|
||||
width = gameObject.frame.realWidth;
|
||||
}
|
||||
|
||||
if (!height && gameObject.frame)
|
||||
{
|
||||
height = gameObject.frame.realHeight;
|
||||
}
|
||||
|
||||
this.world.staticTree.remove(this);
|
||||
|
||||
this.width = width;
|
||||
|
|
Loading…
Reference in a new issue