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:
Is there a limit to the amount of space to be used for drawables?
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:
- Yes, there is a limit. Setting BitmapFactory.Options.inPurgeable to true , calling recycle() method of the Bitmap when necessary will help a lot.
- 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.
精彩评论