Alex Rivera | Logout

Android drawBitmap Performance For Lots of Bitmaps?

Asked 2011-02-13T00:51:59.977
9

I'm in the process of writing an Android game and I seem to be having performance issues with drawing to the Canvas. My game has multiple levels, and each has (obviously) a different number of objects in it.

The strange thing is that in one level, which contains 45 images, runs flawlessly (almost 60 fps). However, another level, which contains 81 images, barely runs at all (11 fps); it is pretty much unplayable. Does this seem odd to anybody besides me?

All of the images that I use are .png's and the only difference between the aforementioned levels is the number of images.

What's going on here? Can the Canvas simply not draw this many images each game loop? How would you guys recommend that I improve this performance?

Thanks in advance.

Edit
Report

1 Answer

0

I encountered a similar problem with performance - ie, level 1 ran great and level 2 didn't

Turned it wasn't the rendering that was a fault (at least not specifically). It was something else specific to the level logic that was causing a bottleneck.

Point is ... Traceview is your best friend.

The method profiling showed where the CPU was spending its time and why the glitch in the framerate was happening. (incidentally, the rendering cost was also higher in Level 2 but wasn't the bottleneck)

answered 2012-09-15T19:03:33.603

Your Answer