سؤال

This question already has an answer here:

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?

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top