memory usage of sprites

0 favourites
  • 6 posts
From the Asset Store
Memory game, with 10 levels for you to have fun. Made in Construct3, template available for purchase.
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)