java - Efficient 2D drawing in Android -
I have searched for a few hours and have not found a brief definite search for my question. I have an application where I have to draw a playground (including all pitch lines) on the screen. So far, I've increased Surface Weave and have copied the rest of the Lunar Lender demo. For all the data, the pitch needs to be pulled in the correct dimensions, which is obtained from a socket that works fine. However, in the minutes of the onDraw () function, I am depicting each frame in each frame which is generating very slow framerate in the emulator (eg ~ 10 fps). Here is my OnDown () function:
@Orride Scared Public Zero (Canvas Canvas) {Canvas Davis (255,0,144,0); Canvas.drawLine (canvas, getFirstLine (), MPEP); Canvas.drawRect (canvas, getFirstRect (), MPEP); Canvas.drawRect (canvas, getSecondRect (), MPent); ... canvas.drawRect (canvas, getSecondRect (), MPP); DrawAnimatedObjects (); }
Then I draw circles and different positions on this background. My question is how do I make it more efficient? Is there any way that I can initially attract the lines of the application and do not have to repeat every frame again?
Thanks for any help.
You definitely have to cache any canvas drawings, which will not change in the bitmap in the initial time And then remove the bitmap on that dot (). This will help in rendering several times:
bitmap mField = null; Zero init () {mField = new bitmap (... dimension ...); Canvas C = new canvas (MFIલ્ડ); C.drawRect (...); ...} Draws on zero (canvas C) {c.drawbitmap (mField); }
Comments
Post a Comment