3D model improvements; Pixel snapping; WebGPU compatibility mode & lots more.
What is the best way to check if object is destroyed with scripting? Is there some kind of "isDestroyed" property I'm missing? If there is still no such property, I'm curious why
You can either use the "instancedestroy" event of IRuntime, the "instancedestroy" event of IObjectClass, or the "destroy" event of IInstance.
Ej.
runtime.addEventListener("instancedestroy", (e) => { });
runtime.objects.Sprite.addEventListener("instancedestroy", (e) => { });
runtime.objects.Sprite.getFirstInstance().addEventListener("destroy", (e) => { });
The event on all of those handlers has an "instance" property which is the instance that was just destroyed.
If you want something like an "isDestroyed" property you can keep track of all created instances in a Set (you can use the "instancecreate" events of IRuntime and IObjectClass to see when something is created) and when something is destroyed, remove it from the Set. Later if some reference you have is not in the Set, you can assume it was destroyed.
So yeah, i HAVE TO build my own system to track destroyed objects. I was wondering exactly about why there is no built-in thing for that, because its seems pretty strange
I think a better way of solving this is sub classing.
construct.net/en/make-games/manuals/construct-3/scripting/guides/subclassing-instances
You still need to manage it yourself, but you can define a sub class of your own with an "isDestoyed" boolean property and in the "instancedestroy" or "destroy" events you just need to update it. No need to keep track of a Set or Map, which could get messy.
construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/iruntime
construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/object-interfaces/iobjectclass
construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/object-interfaces/iinstance
construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/interfaces/instance-event