I am working on a board game that uses coins on a board. I drew the board using the drawLine
function but am trying to see how to place a coin on this board and move it. Ca开发者_C百科n someone tell what's the best way to do this? I see I can use the drawCircle
function of the canvas class or the drawBitmap
function. Is there another way to do this? I need to place the coins at the start position and then move them to a different position on the board as the game progresses.
Thanks.
The best way, at list visually, would be to create Drawable objects, loaded from ressources files (png images). Then for call the Drawable.setBounds(Rect bounds) and the Drawable.draw(Canvas c).
You can use this in a loop, for each of your coin, by just updating the bounds (ie the rectangle in which the image must be drawn).
A good idea would be to take a look at the LunarLander sample code : http://developer.android.com/resources/samples/LunarLander/index.html
精彩评论