mirror of
https://github.com/photonstorm/phaser
synced 2024-11-26 22:52:14 +00:00
Merge pull request #961 from Phaiax/issue-bodyEnable
Body.enable only exists in Arcade physics, so move conditions concerning...
This commit is contained in:
commit
7fa3110c06
3 changed files with 25 additions and 15 deletions
|
@ -155,7 +155,7 @@ Phaser.Sprite = function (game, x, y, key, frame) {
|
|||
|
||||
/**
|
||||
* A small internal cache:
|
||||
*
|
||||
*
|
||||
* 0 = previous position.x
|
||||
* 1 = previous position.y
|
||||
* 2 = previous rotation
|
||||
|
@ -209,7 +209,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
|
|||
this._cache[1] = this.world.y;
|
||||
this._cache[2] = this.rotation;
|
||||
|
||||
if (this.body && this.body.enable)
|
||||
if (this.body)
|
||||
{
|
||||
this.body.preUpdate();
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
|
|||
|
||||
this.animations.update();
|
||||
|
||||
if (this.body && this.body.enable)
|
||||
if (this.body)
|
||||
{
|
||||
this.body.preUpdate();
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ Phaser.Sprite.prototype.postUpdate = function() {
|
|||
this.key.render();
|
||||
}
|
||||
|
||||
if (this.exists && this.body && this.body.enable)
|
||||
if (this.exists && this.body)
|
||||
{
|
||||
this.body.postUpdate();
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ Phaser.Sprite.prototype.postUpdate = function() {
|
|||
Phaser.Sprite.prototype.loadTexture = function (key, frame) {
|
||||
|
||||
frame = frame || 0;
|
||||
|
||||
|
||||
this.key = key;
|
||||
|
||||
if (key instanceof Phaser.RenderTexture)
|
||||
|
@ -531,10 +531,10 @@ Phaser.Sprite.prototype.updateCrop = function() {
|
|||
/**
|
||||
* Crop allows you to crop the texture used to display this Sprite.
|
||||
* This modifies the core Sprite texture frame, so the Sprite width/height properties will adjust accordingly.
|
||||
*
|
||||
*
|
||||
* Cropping takes place from the top-left of the Sprite and can be modified in real-time by either providing an updated rectangle object to Sprite.crop,
|
||||
* or by modifying Sprite.cropRect (or a reference to it) and then calling Sprite.updateCrop.
|
||||
*
|
||||
*
|
||||
* The rectangle object given to this method can be either a Phaser.Rectangle or any object so long as it has public x, y, width and height properties.
|
||||
* A reference to the rectangle is stored in Sprite.cropRect unless the `copy` parameter is `true` in which case the values are duplicated to a local object.
|
||||
*
|
||||
|
@ -809,7 +809,7 @@ Phaser.Sprite.prototype.play = function (name, frameRate, loop, killOnComplete)
|
|||
* Checks to see if the bounds of this Sprite overlaps with the bounds of the given Display Object, which can be a Sprite, Image, TileSprite or anything that extends those such as a Button.
|
||||
* This check ignores the Sprites hitArea property and runs a Sprite.getBounds comparison on both objects to determine the result.
|
||||
* Therefore it's relatively expensive to use in large quantities (i.e. with lots of Sprites at a high frequency), but should be fine for low-volume testing where physics isn't required.
|
||||
*
|
||||
*
|
||||
* @method Phaser.Sprite#overlap
|
||||
* @memberof Phaser.Sprite
|
||||
* @param {Phaser.Sprite|Phaser.Image|Phaser.TileSprite|Phaser.Button|PIXI.DisplayObject} displayObject - The display object to check against.
|
||||
|
|
|
@ -173,7 +173,7 @@ Phaser.TileSprite.prototype.preUpdate = function() {
|
|||
this._cache[1] = this.world.y;
|
||||
this._cache[2] = this.rotation;
|
||||
|
||||
if (this.body && this.body.enable)
|
||||
if (this.body)
|
||||
{
|
||||
this.body.preUpdate();
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ Phaser.TileSprite.prototype.preUpdate = function() {
|
|||
this.tilePosition.y += this._scroll.y * this.game.time.physicsElapsed;
|
||||
}
|
||||
|
||||
if (this.body && this.body.enable)
|
||||
if (this.body)
|
||||
{
|
||||
this.body.preUpdate();
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ Phaser.TileSprite.prototype.update = function() {
|
|||
*/
|
||||
Phaser.TileSprite.prototype.postUpdate = function() {
|
||||
|
||||
if (this.exists && this.body && this.body.enable)
|
||||
if (this.exists && this.body)
|
||||
{
|
||||
this.body.postUpdate();
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ Phaser.TileSprite.prototype.stopScroll = function() {
|
|||
Phaser.TileSprite.prototype.loadTexture = function (key, frame) {
|
||||
|
||||
frame = frame || 0;
|
||||
|
||||
|
||||
this.key = key;
|
||||
|
||||
if (key instanceof Phaser.RenderTexture)
|
||||
|
@ -496,7 +496,7 @@ Phaser.TileSprite.prototype.play = function (name, frameRate, loop, killOnComple
|
|||
* Resets the TileSprite. This places the TileSprite at the given x/y world coordinates, resets the tilePosition and then
|
||||
* sets alive, exists, visible and renderable all to true. Also resets the outOfBounds state.
|
||||
* If the TileSprite has a physics body that too is reset.
|
||||
*
|
||||
*
|
||||
* @method Phaser.TileSprite#reset
|
||||
* @memberof Phaser.TileSprite
|
||||
* @param {number} x - The x coordinate (in world space) to position the Sprite at.
|
||||
|
@ -525,7 +525,7 @@ Phaser.TileSprite.prototype.reset = function(x, y) {
|
|||
this._cache[4] = 1;
|
||||
|
||||
return this;
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -365,6 +365,11 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
*/
|
||||
preUpdate: function () {
|
||||
|
||||
if (!this.enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.phase = 1;
|
||||
|
||||
// Store and reset collision flags
|
||||
|
@ -440,6 +445,11 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
*/
|
||||
postUpdate: function () {
|
||||
|
||||
if (!this.enable)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only allow postUpdate to be called once per frame
|
||||
if (this.phase === 2)
|
||||
{
|
||||
|
@ -612,7 +622,7 @@ Phaser.Physics.Arcade.Body.prototype = {
|
|||
|
||||
this._sx = this.sprite.scale.x;
|
||||
this._sy = this.sprite.scale.y;
|
||||
|
||||
|
||||
this.center.setTo(this.position.x + this.halfWidth, this.position.y + this.halfHeight);
|
||||
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue