mirror of
https://github.com/photonstorm/phaser
synced 2024-11-22 20:53:39 +00:00
Sprite.destroy is back in business.
This commit is contained in:
parent
574f4f351b
commit
e98aa205ea
5 changed files with 72 additions and 5 deletions
|
@ -116,6 +116,8 @@ Version 1.0.7 (in progress in the dev branch)
|
|||
* Tweens .to will now always return the parent (thanks powerfear)
|
||||
* You can now pass a PIXI.Texture to Sprite (you also need to pass a Phaser.Frame as the frame parameter) but this is useful for Sprites sharing joint canvases.
|
||||
* Fixed Issue #101 (Mouse Button 0 is not recognised, thanks rezoner)
|
||||
* Added Sprite.destroy back in again and made it a lot more robust at cleaning up child objects.
|
||||
|
||||
|
||||
|
||||
* TODO: look at Sprite.crop (http://www.html5gamedevs.com/topic/1617-error-in-spritecrop/)
|
||||
|
|
|
@ -50,9 +50,10 @@
|
|||
|
||||
// layer.sprite.scale.setTo(2, 2);
|
||||
|
||||
game.add.sprite(320, 0, layer.texture, layer.frame);
|
||||
game.add.sprite(0, 200, layer.texture, layer.frame);
|
||||
game.add.sprite(320, 200, layer.texture, layer.frame);
|
||||
// Works a treat :)
|
||||
// game.add.sprite(320, 0, layer.texture, layer.frame);
|
||||
// game.add.sprite(0, 200, layer.texture, layer.frame);
|
||||
// game.add.sprite(320, 200, layer.texture, layer.frame);
|
||||
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
}
|
||||
|
|
|
@ -34,4 +34,36 @@ Phaser.Events = function (sprite) {
|
|||
this.onAnimationComplete = null;
|
||||
this.onAnimationLoop = null;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Events.prototype = {
|
||||
|
||||
destroy: function () {
|
||||
|
||||
this.parent = null;
|
||||
this.onAddedToGroup.dispose();
|
||||
this.onRemovedFromGroup.dispose();
|
||||
this.onKilled.dispose();
|
||||
this.onRevived.dispose();
|
||||
this.onOutOfBounds.dispose();
|
||||
|
||||
if (this.onInputOver)
|
||||
{
|
||||
this.onInputOver.dispose();
|
||||
this.onInputOut.dispose();
|
||||
this.onInputDown.dispose();
|
||||
this.onInputUp.dispose();
|
||||
this.onDragStart.dispose();
|
||||
this.onDragStop.dispose();
|
||||
}
|
||||
|
||||
if (this.onAnimationStart)
|
||||
{
|
||||
this.onAnimationStart.dispose();
|
||||
this.onAnimationComplete.dispose();
|
||||
this.onAnimationLoop.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
|
@ -580,6 +580,30 @@ Phaser.Sprite.prototype.kill = function() {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
* @method Phaser.Sprite.prototype.destroy
|
||||
*/
|
||||
Phaser.Sprite.prototype.destroy = function() {
|
||||
|
||||
if (this.group)
|
||||
{
|
||||
this.group.remove(this);
|
||||
}
|
||||
|
||||
this.input.destroy();
|
||||
this.events.destroy();
|
||||
this.animations.destroy();
|
||||
|
||||
this.alive = false;
|
||||
this.exists = false;
|
||||
this.visible = false;
|
||||
|
||||
this.game = null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Description.
|
||||
*
|
||||
|
|
|
@ -197,12 +197,20 @@ Phaser.TilemapLayer.prototype = {
|
|||
return;
|
||||
}
|
||||
|
||||
this._prevX = this._dx;
|
||||
this._prevY = this._dy;
|
||||
|
||||
this._dx = -(this._x - (this._startX * this.tileWidth));
|
||||
this._dy = -(this._y - (this._startY * this.tileHeight));
|
||||
|
||||
this._tx = this._dx;
|
||||
this._ty = this._dy;
|
||||
|
||||
// First let's just copy over the whole canvas, offset by the scroll difference
|
||||
|
||||
// Then we only need fill in the missing strip/s (could be top/bottom/left/right I guess)
|
||||
// ScrollZone code might be useful here.
|
||||
|
||||
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
|
||||
|
||||
for (var y = this._startY; y < this._startY + this._maxY; y++)
|
||||
|
@ -260,11 +268,11 @@ Phaser.TilemapLayer.prototype.deltaAbsY = function () {
|
|||
}
|
||||
|
||||
Phaser.TilemapLayer.prototype.deltaX = function () {
|
||||
return this._x - this._prevX;
|
||||
return this._dx - this._prevX;
|
||||
}
|
||||
|
||||
Phaser.TilemapLayer.prototype.deltaY = function () {
|
||||
return this._y - this._prevY;
|
||||
return this._dy - this._prevY;
|
||||
}
|
||||
|
||||
Object.defineProperty(Phaser.TilemapLayer.prototype, "x", {
|
||||
|
|
Loading…
Reference in a new issue