在 AS3 中维护两点之间的 lineTo 最有效的方法是什么?
我正在寻找一种最有效的方法来维持 AS3 中两点与一条线的连接。基本上,我有一大堆四处移动的圆圈,并且有一个属性 subNode
,它将充当线条的终点。
目前,我的做法非常密集:
if(_line != null) _line.parent.removeChild(_line);
_line = new Sprite();
_line.graphics.lineStyle(1, 0xE1164B);
_line.graphics.lineTo(subNode.x - x, subNode.y - y);
addChild(_line);
是否可能只是一个 redrawLine()
或者我缺少的东西?
I'm looking to work out the most efficient way to maintain the joining of two points with a line in AS3. Basically, I have a whole bunch of circles that move around, and have a property subNode
which will act as an end point for the line.
At the moment, the way I'm doing it is extremely intensive:
if(_line != null) _line.parent.removeChild(_line);
_line = new Sprite();
_line.graphics.lineStyle(1, 0xE1164B);
_line.graphics.lineTo(subNode.x - x, subNode.y - y);
addChild(_line);
Is there maybe just a redrawLine()
or something that I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不必每次都实例化 Sprite。在这种情况下,
Shape
也应该足够了。您还应该考虑何时划清界限。也许只有当子节点移动时。但没有足够的代码来正确回答这个问题。
You don't have to instantiate a Sprite every time. Also a
Shape
should be enough in this case.Also you should think about when to draw the line. Maybe only if the subNode hase moved. But there is not enough code for a proper answer to that.