How do I choose one image from many of possibilities at runtime?

0 favourites
  • 4 posts
From the Asset Store
Antisuspend Plugin for Construct 3 prevents the runtime from getting suspended.
  • Hi :-)

    Say I have 500 low res (50x50 pixels) images. Each image depicts a different animal.

    Desired outcome:

    1. I want to be able to choose one of these images and display it on screen

    2. Then repeat step 1 up to 75 times (so at max, have 75 50x50 picture on screen at the same time)

    Questions:

    a) Is this realistic, memory-wise, for a web-based game? or is this too many images at once?

    b) How do I achieve this?

    with my limited knowledge of construct, the only way I can think of is having a single sprite, with the 500 pictures as individual frames of said sprite. Then I can create this sprite and choose the desired frame. However I'm afraid this is terribly memory inefficient and would quickly cause the game to crash - am I right? or is it indeed possible to have tens of instances of a sprite with hundreds of frames?

    Thanks!

  • Hmmm, good question! So as my knowledge, construct 3 should run normal possibly with a lag spike. I will try it soon as possible, and I will then help you further.

    But I thing it is possible.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sounds like something C3 could handle no problem.

    A 50 x 50 pixels image at 32 bit depth should be around 10 Kilobytes (just tried it by creating one in Windows), which isn't a lot. 500 images of 10 kilobytes would be 5000 kilobytes, which is 5 megabytes, which is still a very small amount of memory.

    The total amount of memory taken shouldn't be a problem at all, as for the rendering...

    If you create an animation with 500 different frames, C3 ends up packing everything together into as few textures as possible.

    Just tried out doing that in the editor to see what would be generated, I created an animation with 500 frames, then right clicked on the project folder in the Project bar and selected Tool > View sprite sheets. C3 ends up creating 8 textures of 2048 x 2048 which will take up 32 megabytes in RAM, which isn't a lot.

    Since all the instances will be of the same object type, it means they will all use the same textures for rendering, so no memory overhead there. All the instances will use the same 32 megabytes of loaded image memory.

    Finally, 75 instances will not be a problem at all.

  • Thank you both very much!

    Then I guess I'll move forward with the project.

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