clipping vs seperate images

for saving image overhead (in filesize as well as in heap) im using big images containing several frames and clip them to the screen.
but this brings big problems in positioning the frames, because you not only need to calculate the position of the frame, moreover the alignment constants become worthless.

so im thinking about storing all frames in one image but to store them in single images instances. but this would cause a bigger heap use and as far as i am concerned these produced images are automatically mutable and dont get stored into vram.

any hints/ comments ?

yet again, ‘it depends’ :wink:

if you are short on heap space, then packing all your frames into a single image will save you alot of heap.

On the flip side, many phones have max. image size limits, so you will need a flexible image packer that will allow the texture page size to be selectable.

There is then the issue of heap fragmentation.

Some phones do not have compacting garbage collectors, other phones make a special case of Image objects and do not compact them.

In this scenario you have 2 possible approaches,

  1. Statically load everything the game needs at initialisation - if this is feasable, then having just a few big images can be beneficial and avoid fragmentation.

  2. if you have too many resources to statically load them all in at once, you are going to have to dynamically reload atleast some of your resources. In this situation, you want to avoid having very large Objects as they will often fail to fit into a fragmented heap.