Question

I'm trying to make a 2D turn based android game that features a grid like board. I have thought up of two different methods of rendering the board:

  1. One big custom View that calculates everything and renders all the tiles. Any animation on any one tile will require the whole view to be re-drawn; so this view will be re-drawing itself all the time.

  2. A big custom ViewGroup with many smaller custom Views, each View representing a single tile. Only tiles that animate need to be redrawn. The ViewGroup is responsible for making sure each View is in the correct location on the screen.

What might be the less resource intensive method? Or is there perhaps an even better method I haven't thought of?

Other factors that may need to be taken into account:

  • Aside from the grid tiles there will be sprites that animate and also move between tiles. The tiles themselves do not translate.

  • The number of tiles on the board is different from game to game but the board is always rectangular.

  • The board is often so big that a typical screen will not fit all the tiles; so the user should be able to pan and zoom on the board.

Was it helpful?

Solution

Go for a big custom View.

If all you are worring about is being less efficient in the drawing process, then you can use invalidate(Rect) et simila to invalidate just some small dirty region. This will redraw only a small region of the View. A big custom View will also simplify animations and other drawing that cross tiles borders.

For implementing pinch-zoom functionalities, take a look here

Why not a game engine such as AndEngine?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top