tags:

views:

24

answers:

1

Currently I have a cartoon character that takes up almost the full screen of a surfaceview, and my little app is only to animate this 2D character during ontouch event at different coordinates.

What I am doing now is to redraw the whole character every single time, and this way I need to have a specific graphic for every single frame.

I am just wondering if its better to split the character into different parts, e.g. heads, hands, legs, and whenever a ontouch event happens, I only need to re-draw the specific part?

What do you think the pros and cons would be? Is it less CPU intensive?

A: 

This really comes down to how your images are set up. Having a single image taking up the whole screen means that every frame has to redraw the whole screen, something which an android device should be capable of doing. If you break your character into different parts it may look as if you only have to redraw a small part of the screen but if you just redraw one part around then it will still be in its old position unless you draw over it meaning you may have to do a full redraw anyway. Sometimes you can be clever and work out what areas of the screen need to be redrawn and then only redraw those but this can get very complicated. Another think worth thinking about is memory usage though, if you have a large number of full screen images in memory some phones may not have enough available memory and may crash. By breaking the image up into small parts you should reduce the chance of this.

skorulis
Thanks for the comment Skorulis, you are right, these are all the concerns I am trying to work out right now. Personally I think the easiest way is to use one single image and redraw the whole screen, just not sure of any performance degradation when the number of images grows...
kolslorr
I don't think you should have any performance degradation unless you are redrawing the screen multiple times per frame. I would be more worried about memory if you expect a lot of images. Remember that even if your PNGs are small they are inflated into a bitmap when you load them.
skorulis