Single sprite with different animations vs multiple sprites

Discussion and feedback on Construct 2

Post » Tue Feb 24, 2015 5:42 pm

Which method is better to use ?

- one single sprite with different animations and all the behaviors (activated only the needed ones)
- multiple sprites (each with only one animation) and the behaviors needed

In other words:
Sprite 1 (animation 1 out of 4 // 1 behavior activated // 3 behaviors deactivated)
Sprite 1 (animation 2 out of 4 // 2 behaviors activated // 2 behaviors deactivated)
Sprite 1 (animation 3 out of 4 // 3 behaviors activated // 1 behavior deactivated)
Sprite 1 (animation 4 out of 4 // 4 behaviors activated // 0 behaviors deactivated)

VS
Sprite 1 (1 animation // 1 behavior (activated))
Sprite 2 (1 animation // 2 behaviors (all activated))
Sprite 3 (1 animation // 3 behaviors (all activated))
Sprite 4 (1 animation // 4 behaviors (all activated))


The game will be for mobiles, so I want to squeeze all the performance I can get (and yeah, I know about https://www.scirra.com/blog/83/optimisa ... -your-time )

I'm asking this because I noticed that the animations of a single object are exported in one image, while animations for different objects are exported in multiple image files.

Also, I have another 2 small questions:
Creating and destroying objects (one at a time) can create junk memory or some slowness ?
Creating the level object by object at the start of the layout from a .json file will have an impact over the performance ?
B
47
S
15
G
6
Posts: 507
Reputation: 7,084

Post » Wed Feb 25, 2015 5:13 pm

Anyone ? ;)
B
47
S
15
G
6
Posts: 507
Reputation: 7,084

Post » Thu Feb 26, 2015 10:05 pm

I want to know this too please!
B
4
Posts: 4
Reputation: 208

Post » Fri Feb 27, 2015 2:25 am

The first one is better.
B
21
S
4
G
4
Posts: 280
Reputation: 2,934

Post » Fri Feb 27, 2015 3:01 am

I prefer "multiple sprites". Because that
1. images would be loaded together for each sprite. If place all images in one sprite, they all will be loaded at the same time.
2. "multiple sprites" is easy to manage in editor.
B
105
S
25
G
216
Posts: 4,294
Reputation: 123,642

Post » Fri Feb 27, 2015 5:35 am

Top one. It's worse to manage, however it's mandatory for performance. Each different sprite object is a different packed draw call. WebGL draws in batches based on the texturemap created by C2. Each Sprite get's a different texturemap. If for any reason you go from map A, to map B then the system needs to unload mapA then load mapB. Now that's fine. however what happens if your doing lot's of different layering with different texture maps. That means WebGL will go from
ABABABABABAB
which means 12 draw calls here. that's low of course, but think abuot many objects like bullets.
where as if you use a single sprite then you just get
AAAAAAAAAAAAA
that's one draw call.

of course if you layer properly you can do
AAAAAABBBBBB
and run on 2 draw calls. But now management of layering is on you :P

Of course you need watch things like 2048x2048 is the max texture size in the safe zone of devices.

top one is better
B
88
S
18
G
9
Posts: 2,455
Reputation: 14,928

Post » Fri Feb 27, 2015 3:35 pm

@jayderyu
From what I understand, draw calls are made only for visible objects ... So I can make the logic of my game using more invisible objects and use only 1 sprite with all the animations for the visuals.

Can you explain me more about "management of layering" ... How can I measure the draw calls to be sure I am in the "safe zone" ?

Also can you answer me my other 2 questions:
Creating and destroying objects (one at a time) can create junk memory or some slowness ?
Creating the level object by object at the start of the layout from a .json file will have an impact over the performance ?

Here is a very alpha version of the game: http://tinyurl.com/blocks191

Thanks :)
B
47
S
15
G
6
Posts: 507
Reputation: 7,084

Post » Fri Feb 27, 2015 5:48 pm

@rexrainbow
Based on performance, which method would be better ?
B
47
S
15
G
6
Posts: 507
Reputation: 7,084

Post » Sat Feb 28, 2015 1:55 am

"From what I understand, draw calls are made only for visible objects ... So I can make the logic of my game using more invisible objects and use only 1 sprite with all the animations for the visuals."

Yes. but that's what you were asking at the top. Which is better.
A. Better for performance
B. Better for object type management
B
88
S
18
G
9
Posts: 2,455
Reputation: 14,928

Post » Sat Feb 28, 2015 9:26 am

Management would be more important than performance gain. And I did not think it would increase performance obviously.
B
105
S
25
G
216
Posts: 4,294
Reputation: 123,642

Next

Return to Construct 2 General

Who is online

Users browsing this forum: Thenonymous and 6 guests