开发者

Flex: Placing items on the canvas element

I am writing simple game on flex. In the ga开发者_开发问答me 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜