开发者

Android - What is the best way to maintain multiple images?

开发者 https://www.devze.com 2023-01-13 02:38 出处:网络
During my game loop I am constantly loading images using BitmapFactory.decodeResource(getResources(), R.drawable.objectx);

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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号