diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index 0bc5cff6e..2fb0ddf9e 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -832,6 +832,8 @@ class RenderedTarget extends Target { */ dispose () { this.runtime.changeCloneCounter(-1); + this.runtime.stopForTarget(this); + this.sprite.removeClone(this); if (this.renderer && this.drawableID !== null) { this.renderer.destroyDrawable(this.drawableID); if (this.visible) { diff --git a/src/sprites/sprite.js b/src/sprites/sprite.js index 3a0402a16..293a1f265 100644 --- a/src/sprites/sprite.js +++ b/src/sprites/sprite.js @@ -58,6 +58,18 @@ class Sprite { } return newClone; } + + /** + * Disconnect a clone from this sprite. The clone is unmodified. + * In particular, the clone's dispose() method is not called. + * @param {!RenderedTarget} clone - the clone to be removed. + */ + removeClone (clone) { + const cloneIndex = this.clones.indexOf(clone); + if (cloneIndex >= 0) { + this.clones.splice(cloneIndex, 1); + } + } } module.exports = Sprite;