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.
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.
See memory usage in the manual.
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.
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.
Develop games in your browser. Powerful, performant & highly capable.
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.