Drawable vs. Bitmap [duplicate]

六眼飞鱼酱① 提交于 2019-11-26 20:06:17

问题


I am writing a real-time game for Android, and after looking at some code from the samples provided in the SDK, I am confused as to when I should use Bitmap or Drawable for my sprites in my game.

What's the difference? Which one is better (faster) for sprites and which one is better for a static background?


回答1:


To get an idea which is better you may want to watch this video:

http://www.youtube.com/watch?v=U4Bk5rmIpic

What is interesting is that he wasn't a java programmer to start with, but an experienced game programmer, and his approach may help you write tests to determine which will be best.

For example, you may find that the Bitmap is better for a background image, if you actually have a static background, but, if you are going to be programmatically changing it then you may have a problem.

There are other considerations besides speed though, as you may find that memory, for example, will be an issue, and how many sprites you want to have on the screen at one time will be an issue.



来源:https://stackoverflow.com/questions/5876952/drawable-vs-bitmap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!