emitter.updateOwnerPos throws an error if emitter is destroyed
How to reproduce:
Make an emitter.
emitter.destroy()
emitter.updateOwnerPos(0,0)
It throws an error that can interrupt js execution.
Emitter.ts:491 Uncaught TypeError: Cannot set properties of null (setting 'x')
at Emitter.updateOwnerPos (Emitter.ts:491:23)
public updateOwnerPos(x: number, y: number): void
{
this._posChanged = true;
this.ownerPos.x = x; // ERROR OCCURS HERE
this.ownerPos.y = y;
}
Yes, it is intended that you don't use an emitter after destroying it. If you just wanted all your particles gone but to continue using the emitter, use Emitter.cleanup().
Yes, but in the event that it is accidentally used after being destroyed - I would assume it would be better to fail silently or log an error than to throw and interrupt execution? A simple
if(this.owner){...}
would prevent it from throwing. This is easy to happen on accident if the emitter is in an array and wasn't removed from the array after being destroyed.