我使用此代码创建了一个drawNode来绘制基元:
var.drawNode = cc.DrawNode.create();
drawNode.drawSegment(this.pos, cc.p(this.pos.x + this.length * Math.sin(this.rotation), this.pos.y + this.length * Math.cos(this.rotation)), STICK_THICKESS, cc.color(255,255,0,255));
它基本上从this.pos中划出一条线到另一点。
现在我想围绕this.pos旋转这条线,所以我想我只需要简单地添加一下:
drawNode.setAnchorPoint(this.pos);
var rotate = cc.RotateBy.create(2, 360);
drawNode.runAction(rotate);
但它仍然围绕一些随机点旋转。
答案 0 :(得分:1)
丑陋但工作方法:
drawNode.setContentSize(1, 1);
drawNode.setAnchorPoint(this.pos);
drawNode.setPosition(this.pos);
var rotate = cc.RotateBy.create(2, 360);
drawNode.runAction(rotate);
在Cocos2d-html5 3.0+中不推荐使用BTW创建方法。使用 cc.rotateBy()代替 cc.RotateBy.Create(), new cc.DrawNode()而不是 cc。 DrawNode.create()