How do I optimize resource usage with instanced animations?

Get help using Construct 2

Post » Mon Aug 31, 2015 5:23 pm

I have one animation for a burning tree. In the first frames it is perfectly healthy, then begins to burn and finally burns down to cinders.

My forest can catch fire. The fire propagates to other trees, destroying large sections of the forest in the end.

Can using instanced sprite animations of just one "burning-tree" animation spare resources in this case? Can I conserve memory and CPU cycles by using only one "burning-tree" animation and starting instances of this one animation at different game-times and screen-coordinates - as the fire propagates?

Eventually I want XCOM-1-style large-scale fires. Does instancing help here conserving memory and some CPU resources? The whole forest fire is just one sprite animation put on the screen at many coordinates at once, playing with different start times. I want to make the instances begin at random times so the burning tree animations on screen will NOT be synchronized.

Can instancing or an other solution preserve resources in this case? Memory, CPU cycles?

Does instancing makes sense in this case?

In 3D rendering, engines can use instanced geometry objects - reserving memory only for one object - and rendering many of its instances.
B
29
S
5
G
5
Posts: 139
Reputation: 5,830

Post » Mon Aug 31, 2015 7:02 pm

I am not very sure if I understand your problem, but I'll try to clear something out.

If your forest is made with one tree, then you can use one sprite for everything. You can create a default animation as let's say "idle", and second animation of the same sprite for burning. Now it would be obviously resource saving to make forest by creating multiple instance of the same tree instead of using many different objects.

If you have many different kind of trees then you might consider creating a separate sprite to imitate the fire which you could spawn on the particular trees. In such case you don't have to put butning animation in each tree sprite which will save some memory for sure.

Anyway many objects/instances will cause performance drop - that's normal, so this is the first thing you should consider for optimisation. Next thing is the "weight" of the images you use for those sprites/animations. The rule is pretty simple, the more objects and sprite animation frames you have in your game the more memory and CPU resources it will take to load it up.
ImageImageImage
B
27
S
16
G
73
Posts: 975
Reputation: 41,159

Post » Tue Sep 01, 2015 12:36 pm

So then if any more than 1 animated sprite is displayed on screen, playing the frames looped, the second sprite will always be an added resource hog, no matter if it's an "instance" of the first sprite or a completely new sprite.

More sprites linearly increase CPU and RAM usage then, I guess.
B
29
S
5
G
5
Posts: 139
Reputation: 5,830

Post » Tue Sep 01, 2015 12:48 pm

Second instance of the same object will also take some RAM memory because game engine generates an object (from the programming term) which needs a possibility to be treated separately in any way. The same goes for animations. Every animation on your screen (no matter if it's an instance of the same object or not) eats some CPU resources because it has to be rendered on the screen separately (it might start burning later or earlier right?).

Now what they have in common (all instances of the same sprite) is the sprite object. Which is simply a - let's say - starting template for the instances. So when you use many different sprites/trees then your game will have to store many "templates" which will use some more memory.
ImageImageImage
B
27
S
16
G
73
Posts: 975
Reputation: 41,159


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 4 guests