SOLVED Question about performance/other using instances in a room.

flyinian

Member
Is there any difference between using an object w/ code and placing it into a room multiple times

vs.

using said before mentioned object and making a child for it and placing the child into a room multiple times?


Would both methods result in the same? As in performance wise and anything else worth mentioning?


I'm leaning on the side that it would be the same, either way.
 

Roldy

Member
Would both methods result in the same? As in performance wise and anything else worth mentioning?
I think there would be subtle performance (both cpu and memory load) differences, but mostly not worth investigating unless you are having specific issues.

The biggest difference is in workflow. The benefits of statically placed instances via the room editor is that you can work in a data driven manner utilizing GMS2 data tools (Room Editor, Instance editor, Object Variable Instance overrides etc..), without having to invent your own tools and systems. Possibly more beneficial is that statically defined instances have constant static instance IDs and are known at compile time as well as being able to access instance meta data via layer_instance_* functions, including in other rooms via layer_set_target_room (this is completely broken on HTML5 btw). This single feature makes GMS2 a very powerful toolset when viewed from a data driven perspective.

Unless your instances need to be programmatically created, for what ever reason, I'd suggest utilizing the tools of the engine. The engine is two parts really; part runtime/platform systems and the toolset/workflow. Abandoning the toolset/workflow without good reason would be foolish IMO.

I'm leaning

Since you are learning you might as well learn to the terminology.

Objects and Instances

Parent and Child
 
Last edited:
Top