views:

101

answers:

1

Hi!

I am writing simple game on flex. In the game there are 2 objects Board and Stone (both are extended from the Canvas super class)

When I started to place Stones instances to the Board Canvas, I come across the problem, I can't understand how to set Stone on the defined position on the board.

So if for example board (canvas) has following attributes: x = 25, y = 25, height = 100, width = 100

How can I for example place a Stone (canvas) in a point 25, 25.

Is there a way to use local board coordinates?

+1  A: 
board.addChild(stone);
stone.x = 25;
stone.y = 25;

Btw, you need not use Canvas for these objects - a Shape or Sprite would be enough. Add the Board sprite to the flex app using rawChildren.addChild(board); Canvas is a Container class for flex ui components.

Amarghosh
Thank you again! Will try sprite. Should I use it for both board and stone objects?
Oleg Tarasenko
yeah, Flex components are for UI development - they have a lot of inbuilt functionalities for that purpose. Why waste them if all you want is moving circles on a board?
Amarghosh
Will try. What I am thinking of, is leave board as it is (Canvas class), and implement stones, as Sprites. Will try this solution today, and then will post if it worked fine with me... Thanks again
Oleg Tarasenko