views:

18

answers:

1

During my game loop I am constantly loading images using

BitmapFactory.decodeResource(getResources(), R.drawable.objectx);

Most of the time I'm calling images that have already been decoded earlier. Am I slowing down execution by decoding the resource every time?
Is it better to store every image into a Map (or Dictionary) at the beginning of the program? If so, how do you get the resource IDs for all images in the drawable folder?

+1  A: 

Is it better to store every image into a Map (or Dictionary) at the beginning of the program?

Yeah... it's much better. Or you can store them as soon as you need them; is not necessary to store them all at the beginning.

If so, how do you get the resource IDs for all images in the drawable folder?

The drawable folder does not contains images only; it also have xml resources. So that's not the way to go.

Cristian
Okay, so as I need an image I'll check if it exists in the map. If it doesn't then I'll decode it and add it. Thanks.
FoppyOmega