* Destroy function * @ignore
()
| 828 | * @ignore |
| 829 | */ |
| 830 | destroy() { |
| 831 | // release the engine's pooled `current.offset` |
| 832 | this._frameAnim.destroy(); |
| 833 | vector2dPool.release(this.offset); |
| 834 | this.offset = undefined; |
| 835 | if (this.isVideo) { |
| 836 | this.removeStatePauseListener(); |
| 837 | this.image.onended = undefined; |
| 838 | this.image.pause(); |
| 839 | this.image.currentTime = 0; |
| 840 | } |
| 841 | this.image = undefined; |
| 842 | // drop the normal-map reference too — same precedent as `image`, |
| 843 | // avoids holding a (possibly large) paired image alive after the |
| 844 | // sprite is gone |
| 845 | this._normalMap = null; |
| 846 | super.destroy(); |
| 847 | } |
| 848 | } |