tobypls
tobypls

Reputation: 849

Using View objects to make simple Android-game

I'm making a board for Android. I use .png images for the board (background) and checker pieces. Basically, it's a game where the graphics are updated upon touch events. It's a school-assignment so I have to use View implementations. For the graphics I've considered two options:

  1. Making a whole "BoardView" class (that extends View) and draw all the graphic components directly on the canvas using onDraw(canvas).

  2. Using ImageView objects to represent each checker piece and the board and putting them on a Layout.

My intuition tells me to use the first method. But my thoughts are that I want to use the pre-implemented TranslateAnimation when a checker is moved. From my understandings; this forces me to use the second method, since I can't animate a Drawable.

Now, to the question: what method is best for me? And if the second; which Layout is preferred to use? I want to be able to overlap the checkers over the board image and compare the ImageView objects' positions to each other to determine where to put the checkers on the board.

Upvotes: 2

Views: 771

Answers (1)

Robin
Robin

Reputation: 10368

Regarding to your simple requirement, I think you can adopt method 2.

Trust me, I have done this kind of stuff years ago, on a legacy linux platform. For these kind of simple game applications, you really do not need to bother with all the frame drawing stuff. Just stick with the existing UI widgets.

This is because the visible elements are all very simple, like cards, static images, blocks etc. You don't need to perform pixel drawing. I have tried to make tetris, mine sweep, and card match games. I even create simple visual effects for it using existing animation facility. That is very easy to do so.

And, of cause, as a software programmer, to write a game using the typical frame by frame approach is much more professional. But it depends on the requirements. Why not using less code to create more value?

Upvotes: 2

Related Questions