tags:

views:

64

answers:

1

Hello, I am new in android development, and I need advice about structure.I want to develop Tic tac toe game, and have 3 images: 1 - 3×3 grid 2 - circle 3- cross.

My idea: I need some layout with background image(3×3 grid) and table 3 x 3 with ImageViews, after clicking on some position we load image(circle or cross) in our table.

Questions:

-First of all is my idea correct?

-I tried to set background with view.setBackgroundResource(res) but it looks not very good, grid(black colour) loading with background colour black ant is difficult to see something.

ps: I found Tic tac toe game example in android sdk, ..\samples\android-8, maybe it helps to somebody

+3  A: 

Your best bet is probably to use a Canvas and draw on it.

There's some great examples included with the SDK. Lunarlander, Jetboy, or maybe Snake.

Edit: Yes, you can. Well kind of...Think of it this way, the order hierarchy of what is displayed is based on the order in which it is drawn. If you did the following, the drawable would be visible over the background:

canvas.drawBitmap(yourBackgroundImage, 0, 0, null);
yourDrawable.setBounds(yourRect);
yourDrawable.draw(canvas);

if you reversed them, the drawable may or may not be visible depending on the background images transparency and size.

yourDrawable.setBounds(yourRect);
yourDrawable.draw(canvas);
canvas.drawBitmap(yourBackgroundImage, 0, 0, null);
In canvas i can set background image?
Sergey
I think you just draw the background image to fit the whole canvas then draw the crosses and circles over it.
AndrewKS