可绘制与位图 [英] Drawable vs. Bitmap

查看:45
本文介绍了可绘制与位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Android 编写实时游戏,在查看 SDK 中提供的示例中的一些代码后,我对何时应该使用 BitmapDrawable 感到困惑 我的游戏中的精灵.

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

有趣的是,他一开始并不是一个 Java 程序员,而是一个经验丰富的游戏程序员,他的方法可以帮助您编写测试以确定哪个是最好的.

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.

例如,您可能会发现 Bitmap 更适合作为背景图像,如果您实际上有一个静态背景,但是,如果您打算以编程方式更改它,那么您可能有一个问题.

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.

这篇关于可绘制与位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆