tags:

views:

78

answers:

1

I want to design a gameboard such as Checkers (but with the possibility of having different board tiles.

Now, OO logic and reason tell me I should have a 'tile' class which I can draw, and I draw x by y number of these on one canvas.

My question is what is the best performant way to draw such a board? Is it reasonable to do it the way I mentioned above and re-draw on changes? Is it better to have an image as my background and 'simulate' a board by snapping to where the tile would be?

Thanks!

+1  A: 

I think you might benefit from checking out the snake game code for android. It has a very straight forward way of using tiles to make a game area.

Biff MaGriff
I did take a look at it, but I'm not sure if that is the best(performant) way to do it. And will Android only re-draw the updated area? Or the entire board?
Steve
You call view.invalidate to refresh. You can pass it a rect
schwiz
schwiz - care to explain please?
Steve
@Steve - It will redraw the entire board.
Biff MaGriff
@Biff - that's what I thought. Anyone have any other solutions to this?
Steve
@Steve - I'm not sure what you are trying to accomplish. Redrawing the entire screen is pretty standard. I do not think you will notice performance issues for tile based game.
Biff MaGriff
Biff - I guess I'm confused. Do I have one view class and create another 'tile class' and in the view class I lay out each of the tiles, which are views itself? I'm a bit confused on the best approach for designing this thing, to where it is efficient and would only redraw the parts that are changed and not the whole thing.
Steve