memory usage of sprites

Get help using Construct 2

Post » Mon Oct 12, 2015 1:14 pm

Hi Guys,

I would like to know if the memory usage is different if you move a sprite with multiple images across the screen compared with a sprite with just one image.

Thank you kindly.
B
4
Posts: 7
Reputation: 442

Post » Mon Oct 12, 2015 2:21 pm

Oops, sorry, I misunderstood I think.
I'm pretty sure the existence of multiple images in a sprite can affect memory usage, but I'm not sure if canvas2d optimizes this by leaving unused animations out of storage. It might be best to test this. Maybe use both types in extreme amounts and see what the difference is in memory use. Node Webkit is likely best for this, since browsers are not exactly stable.
Other post:
Not sure how canvas2d does it's thing, and I don't know much about the technical side of memory to begin with, but speaking logically;
If the single sprite contains less data than the many, it's probably more effective. If it contains the same amount of data, it's less effective in principle, since the location and other information has to be stored about the object, not just the image.

Transparency also causes much more of an impact in CPU usage on several overlapping sprites than on one sprite.

My advice is that if it's plausible and a one off thing and the sprites would always be together, (the individual sprites aren't used in different configurations or anything) then it might be best to optimize there, and make it one sprite. If it recurs enough and often enough that all these sprites have to move in unison, it's probably best to optimize it as above.
B
42
S
14
G
3
Posts: 165
Reputation: 5,115

Post » Mon Oct 12, 2015 2:52 pm

See memory usage in the manual.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,454

Post » Tue Oct 13, 2015 10:19 am

Thanks for the replies!

@Ashley, I'm not sure the manual entry you pointed me to actually answers my question, or perhaps I just misunderstood.

I'm trying to work out if moving a sprite (containing 20 images) across the screen will use up more memory than moving a sprite with just one.

Perhaps it'd help to provide a use case scenario: I have a a collection of sprites and each contains an animation of around 10 images. This animation only needs to play when the sprite is touched.

As each sprite move around the screen, their movement appears to be rather clunky. So I wondered if it would provide smoother performance, if I used a sprite with a single image, to move around the screen. Then destroy the single image sprite and replace it with another sprite that contains the animation, when needed.

Thanks again for your help.
B
4
Posts: 7
Reputation: 442

Post » Tue Oct 13, 2015 10:39 am

I'm not sure why your question mentions that the sprite is moving - it has no effect on the memory usage if it moves of stays still.

As the memory usage manual entry says, "Sprites are either fully loaded in to memory, or not at all" - so the fewer frames a sprite has, the less memory it will use. But if you put those frames in to different sprites on the same layout, it's the same.
Scirra Founder
B
387
S
230
G
88
Posts: 24,251
Reputation: 192,454

Post » Tue Oct 13, 2015 11:55 am

Thanks for your reply @Ashley.

I just thought a moving sprite would use up more memory, as the system not only needs to redraw the sprite image, but also calculate it's movement too. But thanks for the clarification, it's always good to learn something new.
B
4
Posts: 7
Reputation: 442


Return to How do I....?

Who is online

Users browsing this forum: Syazanie Amirin and 9 guests