Reputation: 12367
Going with the time I try to implement view pager in my tile based game - and swiping is janky. I performed necessary performance measures like suggested by @romangui , and found out that redrawing my gaem field takes about 48 msec (way too long) - and I already flattened layout, eliminated overdraw have my custom layout managers etc.
I discovered that drawing one tile on GN takes about 0.600 msec - way too long for all 81 tiles. Time is actually spend on Canvas.drawBitmap(...)
Any ideas how to improve performance? I have only 6 different bitmaps, they are loaded once and reused. ARGB_8888. Of course they to not necessarilly match actual displayed size.
Would I get better performance if I pre render them for actual display size after my layout was measured?
Or shall I bite the bullet and pre render one big bitmap with my game state just for scrolling?
Upvotes: 3
Views: 5528
Reputation: 24464
You should be sure that you do not make Android to use scaling of the images while drawing.
Try to use previously scaled images, as in Draw a scaled bitmap to the canvas?
Upvotes: 6