mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
Removed Circle functions and updated setSize docs.
This commit is contained in:
parent
9b9e398c73
commit
e974ff4ee9
1 changed files with 13 additions and 47 deletions
|
@ -625,17 +625,24 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You can modify the size of the physics Body to be any dimension you need.
|
* You can modify the size of the physics Body to be any dimension you need.
|
||||||
* So it could be smaller or larger than the parent Sprite. You can also control the x and y offset, which
|
* This allows you to make it smaller, or larger, than the parent Sprite.
|
||||||
* is the position of the Body relative to the top-left of the Sprite.
|
* You can also control the x and y offset of the Body. This is the position of the
|
||||||
|
* Body relative to the top-left of the Sprite _texture_.
|
||||||
*
|
*
|
||||||
* Calling `setSize` will have no effect if you have previously used `Body.setCircle`. To change a collision
|
* For example: If you have a Sprite with a texture that is 80x100 in size,
|
||||||
* circle use `setCircle` instead.
|
* and you want the physics body to be 32x32 pixels in the middle of the texture, you would do:
|
||||||
|
*
|
||||||
|
* `setSize(32, 32, 24, 34)`
|
||||||
|
*
|
||||||
|
* Where the first two parameters is the new Body size (32x32 pixels).
|
||||||
|
* 24 is the horizontal offset of the Body from the top-left of the Sprites texture, and 34
|
||||||
|
* is the vertical offset.
|
||||||
*
|
*
|
||||||
* @method Phaser.Physics.Arcade.Body#setSize
|
* @method Phaser.Physics.Arcade.Body#setSize
|
||||||
* @param {number} width - The width of the Body.
|
* @param {number} width - The width of the Body.
|
||||||
* @param {number} height - The height of the Body.
|
* @param {number} height - The height of the Body.
|
||||||
* @param {number} [offsetX] - The X offset of the Body from the Sprite position.
|
* @param {number} [offsetX] - The X offset of the Body from the top-left of the Sprites texture.
|
||||||
* @param {number} [offsetY] - The Y offset of the Body from the Sprite position.
|
* @param {number} [offsetY] - The Y offset of the Body from the top-left of the Sprites texture.
|
||||||
*/
|
*/
|
||||||
setSize: function (width, height, offsetX, offsetY) {
|
setSize: function (width, height, offsetX, offsetY) {
|
||||||
|
|
||||||
|
@ -659,47 +666,6 @@ Phaser.Physics.Arcade.Body.prototype = {
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets this Body as using a circle, of the given radius, for all collision detection instead of a rectangle.
|
|
||||||
* The radius is given in pixels and is the distance from the center of the circle to the edge.
|
|
||||||
*
|
|
||||||
* You can also control the x and y offset, which is the position of the Body relative to the top-left of the Sprite.
|
|
||||||
*
|
|
||||||
* @method Phaser.Physics.Arcade.Body#setCircle
|
|
||||||
* @param {number} [radius] - The radius of the Body in pixels. Pass a value of zero / undefined, to stop the Body using a circle for collision.
|
|
||||||
* @param {number} [offsetX] - The X offset of the Body from the Sprite position.
|
|
||||||
* @param {number} [offsetY] - The Y offset of the Body from the Sprite position.
|
|
||||||
*/
|
|
||||||
setCircle: function (radius, offsetX, offsetY) {
|
|
||||||
|
|
||||||
if (offsetX === undefined) { offsetX = this.offset.x; }
|
|
||||||
if (offsetY === undefined) { offsetY = this.offset.y; }
|
|
||||||
|
|
||||||
if (radius > 0)
|
|
||||||
{
|
|
||||||
this.isCircle = true;
|
|
||||||
this.radius = radius;
|
|
||||||
|
|
||||||
this.sourceWidth = radius * 2;
|
|
||||||
this.sourceHeight = radius * 2;
|
|
||||||
|
|
||||||
this.width = this.sourceWidth * this._sx;
|
|
||||||
this.height = this.sourceHeight * this._sy;
|
|
||||||
|
|
||||||
this.halfWidth = Math.floor(this.width / 2);
|
|
||||||
this.halfHeight = Math.floor(this.height / 2);
|
|
||||||
|
|
||||||
this.offset.setTo(offsetX, offsetY);
|
|
||||||
|
|
||||||
this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.isCircle = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets all Body values (velocity, acceleration, rotation, etc)
|
* Resets all Body values (velocity, acceleration, rotation, etc)
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue