Memory usage question

Get help using Construct 2

Post » Wed May 01, 2013 7:35 pm

I've got a question about memory and loading sprites. Lets say I have a terrain made of N 32x32 pixel sprites. Suppose that each terrain sprite could have 1 of 8 possible images. Would it be more efficient to create one sprite with a sprite sheet that has all 8 frames? Or would it be more efficient to create 8 different sprites each with 1 frame?

It seems to me that having each sprite on the layout contain all 8 frames would be more memory intensive than having 8 different sprites each with 1 frame.

Can anyone answer this?
B
45
S
13
G
7
Posts: 34
Reputation: 5,919

Post » Wed May 01, 2013 7:43 pm

It'd be the same thing, since sprites are fully loaded into memory (with every single animation and frame) as soon as the layout starts.

Also, relevant. If you're really haggling for memory then you should probably just use one or two base layers as tiled backgrounds, then sprinkle them with sprites to add variety.
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Wed May 01, 2013 7:49 pm

Thank you for the quick response. I just read that post. It's what made me finally pose this question.

But isn't each sprite created on the layout a new instance? Meaning that each one would contain the 8 frame sprite sheet, variables, etc? Or is it simply drawing that one sprite to the screen in multiple locations?
B
45
S
13
G
7
Posts: 34
Reputation: 5,919

Post » Wed May 01, 2013 7:51 pm

There is GPU/CPU overhead for running multiple instances of the same sprite, but in terms of memory usage it's treated as a single object.
B
56
S
15
G
10
Posts: 910
Reputation: 11,942

Post » Wed May 01, 2013 8:13 pm

Thank you! I know this is common in other engines. Just wasn't sure if it worked the same in html5.
B
45
S
13
G
7
Posts: 34
Reputation: 5,919


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests