Multiple animations per object

Discussion and feedback on Construct 2

Post » Mon Sep 16, 2013 6:52 pm

I've been putting a lot of animations on 1 sprite and using "create object > set animation to: ".

I'm wondering, when it does this, is it technically loading every animation when the sprite is created? Should I be using separate sprites for each animation for something like this?
B
40
S
12
G
1
Posts: 532
Reputation: 4,147

Post » Tue Sep 17, 2013 4:08 pm

I am fairly certain that all a sprite's animations are loaded when it is created. If you have multiple instances of the same sprite, though, it does not load the animations for it multiple times since the animations are already loaded from the very first instance.

I've seen many people recommend using one sprite for objects that behave the same. So I think you are following good procedure.
B
26
S
8
G
2
Posts: 33
Reputation: 3,645

Post » Tue Sep 17, 2013 6:59 pm

@aerirprown - Right, but what I'm basically doing is when an enemy dies, I spawn a "death" sprite and destroy the enemy immediately. Once I have more enemies in game, this sprite can become quite large with tons of animations that might only be used a couple times per layout.

So I'm betting it's probably smarter to not do it this way?
B
40
S
12
G
1
Posts: 532
Reputation: 4,147

Post » Tue Sep 17, 2013 7:27 pm

Animations are just references to sprites on a sprite sheet, so depending on where that image is, it is "loading" a certain subset of images.

Lets say you have 10 animations with 20 frames a piece, that is going to be broken up into a couple of sprite sheets.

Are you worried about memory or performance?
B
30
S
10
G
7
Posts: 416
Reputation: 7,239

Post » Tue Sep 17, 2013 7:57 pm

@firebelly - I'm worried about both. If I have 40 enemies and each of them have a 10 frame animation that I put into 1 sprite, it would affect the memory and performance if I'm loading that for only 1 animation at a time and then destroying it, no?
B
40
S
12
G
1
Posts: 532
Reputation: 4,147

Post » Tue Sep 17, 2013 8:33 pm

I had a large animation(large in pixels not frames) that made my game stutter for a second when it was created. So I just spawned it on the start of the layout and toggled between visible/invisible and placed it in the correct place.

That way you could avoid constantly creating and destroying the animation.
B
26
S
8
G
2
Posts: 33
Reputation: 3,645

Post » Wed Sep 18, 2013 6:13 pm

@ aerirprown - I suppose that makes sense. Thanks!
B
40
S
12
G
1
Posts: 532
Reputation: 4,147


Return to Construct 2 General

Who is online

Users browsing this forum: Lorvin, Refeuh and 3 guests