Android: Is there any way of speeding up canvas.drawBitmap?
Simple question, not sure sure there’s a simple answer though!!
Is there anything at all that I can do to speed up my surfaceview drawing?
I’m using something like this:
c.drawBitmap(scaledSprite, X, Y, redPaint);
The method that I’m using has to draw about 25 of these sprites on the screen, so I’m using a for loop, meaning it has to display 25 during a frame.
Now, this works absolutely fine on the 3 phones that I’ve tested on, but on a tablet, it just slows down. I’ve commented out all the other drawing methods and left just this one and this is definitely what is slowing the game down.
Are there any clever tips anyone can give me to speed this up?
I know open GL is a possibility but the bulk of the game is now written so I don’t really want to make any drastic changes now if I can help it.
One Solution collect form web for “Android: Is there any way of speeding up canvas.drawBitmap?”
If you set your SurfaceView to lower quality graphics
and load all bitmaps in the same config
Options options = new BitmapFactory.Options(); options.inScaled = false; options.inPreferredConfig = Bitmap.Config.RGB_565;
This would make it faster, plus you would need to make variable movement speed of sprites depending on the frame delay.
However, even with these settings an arcade game with many sprites will not work well on a tablet, hence, I am afraid, if you want to make a proper game that sells, you must create an OpenGl framework or use ready made ones.