我有一个任务:
我需要在一张画布上放置大约 100 个精灵(上面有准备好的网格)。我需要将它们作为不可见的(圆形)石头放在板上,并且仅在鼠标悬停时才可见。
我遇到的问题是,我无法将这些对象准确地放入网格上的节点中。
例如
如果我这样定义石头(它只是一个精灵,正如我之前所说的):
var stone:StoneSprite = new StoneSprite();
stone.x = this.x + 2*cellWidth;
stone.graphics.beginFill( 0x000000 );
stone.graphics.drawCircle(stone.x , this.y + cellWidth, cellWidth/3 );
stone.graphics.endFill();
rawChildren.addChild(stone);
他们不坐在节点上......见图片:http: //img.skitch.com/20091014-kuhfyjeg1g5qmrbyxbcerp4aya.png
如果我这样做:
var stone:StoneSprite = new StoneSprite();
stone.graphics.beginFill( 0x000000 );
stone.graphics.drawCircle(this.x + 2*cellWidth , this.y + cellWidth, cellWidth/3 );
stone.graphics.endFill();
rawChildren.addChild(stone);
石头在网格节点中正确显示...参见图 2:http: //img.skitch.com/20091014-f595tksjxramt98s7yfye591bh.png
所以我想知道这两种方法有什么区别。
另外,我认为我需要将正确的坐标传递给石头类......如果我想更改石头对象的某些属性。例如能见度或半径。
- 您能否建议,将坐标定义为stone.x,stone.y有什么问题
- 如何解决定位不正确的问题。
真的很感激关于这个问题的想法,我试图解决这么长时间:(