开发者

Problems with drawables in 2D game

Hey guys, I'm working on a 2D game for android, but I keep running into problems when attempting to use drawables with a surfaceview. When assigning a image to a drawable I am only allowed up 开发者_如何学运维to around 2 mb of total space from the drawables. Then I start getting null pointer exceptions when trying to draw the image or set the bounds. So in the end I have two questions:

  1. Is there a limit to the amount of space to be used for drawables?

  2. Is there a more effective way to draw images with a surfaceview?


I've come across with the same problems, and here are my answers:

  1. Yes, there is a limit. Setting BitmapFactory.Options.inPurgeable to true , calling recycle() method of the Bitmap when necessary will help a lot.
  2. So far as I know, the fastest way to draw 2d sprites is creating a canvas by calling the constructor Canvas(GL gl) in a GLSurfaceView.
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜