Memory usage with externally loaded images

This forum is currently in read-only mode.
From the Asset Store
500 monsters and creatures images for card games - Set 1
  • Hi there,

    I recently stumbled across a memory issue in my coding logic.

    Here's the deal:

    The map format for my game is like using tiled backgrounds for walls / floors (2d topdown here) and loading their textures from file.

    The procedure:

    -Get no. of backgrounds to load

    -Execute loop "load walls / floors" X times

    -On loop "load wall / floors"

    -->Create tiled background with dimensions X,Y at PosX, PosY

    -->load image file apppath + "Textures\" + $texturename +".png"

    This results in inefficient memory usage since every time I create a background I load the file from disk, no matter if the same png file has been loaded before, e.g. I have 20 walls that use the texture "concrete.png", "concrete.png" will be dumped 20 times into memory, unnecessarily growing the memory usage.

    I thought I would do something clever and tried Image Manipulator so far, abusing a dummy sprite as texture buffer, iterating through the map file and count the number of different textures to load, load them into the frames of the dummy sprite, then in the loading loop switching to the relevant frame number, copy the frame with Image Manipulator, creating the background and the using Image Manipulator again to drop the texture on the background.

    This didn't work :/

    Is there a way around it without giving up the feature of dynamically loading textures from disk?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There's no need to reload a texture once its already in use.

    Try creating another instance instead.

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