Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将SKShape节点绑定到CGPathGetCurrentPoint_Ios_Objective C_Sprite Kit_Skshapenode - Fatal编程技术网

Ios 将SKShape节点绑定到CGPathGetCurrentPoint

Ios 将SKShape节点绑定到CGPathGetCurrentPoint,ios,objective-c,sprite-kit,skshapenode,Ios,Objective C,Sprite Kit,Skshapenode,我尝试将SKShapeNode绑定到我的圆的CGPathGetCurrentPoint。但这条路似乎并没有走 CGPoint d; ... myPath = CGPathCreateMutable(); CGPathAddArc(myPath, NULL, 0,0, 60, 10, M_PI*2, YES); arc = [SKShapeNode node]; arc.path = myPath; ... [self addChild:arc]; 这里一切都好。然后我把球接到弧

我尝试将SKShapeNode绑定到我的圆的CGPathGetCurrentPoint。但这条路似乎并没有走

    CGPoint d;
...
myPath = CGPathCreateMutable();
CGPathAddArc(myPath, NULL, 0,0, 60, 10, M_PI*2, YES);

 arc = [SKShapeNode node];
 arc.path = myPath;
...
[self  addChild:arc];
这里一切都好。然后我把球接到弧上

ball = [SKShapeNode node];
ball.path = ballPath.CGPath;
[self addChild:ball];
...
d = CGPathGetCurrentPoint(arc.path);
 ball.position =  CGPointMake(d.x, d.y);
在TouchsMoved中,我为我的弧放置了旋转代码

arc.zRotation+=angleRadians*4;
d = CGPathGetCurrentPoint(arc.path);
 ball.position =  CGPointMake(d.x, d.y);

什么也没发生。我希望球连接到弧电流点并随它移动

角度弧度设置为什么?您是否在代码中的某个地方实例化了ball节点?当我运行应用程序时,一切都正常。球放在正确的位置。但当我旋转弧线球时,它保持在先前的位置,不跟随弧线当前点。这条路好像不动了。我不明白它是什么。@user2277872我测试了不同的变体,现在我确切地知道路径不会移动。因为当我增加一条线时,我的球改变了位置。但不要用圆弧旋转。有什么想法吗?我认为当您更改CGPath的内容时,形状节点不会更改,如果您希望形状节点更改其形状,您必须重新分配,或者甚至创建CGPath的新版本,然后再次分配。似乎您在CGPathGetCurrentPoint的成因上弄错了。CGPathGetCurrentPoint返回添加到路径的最后一个点。所以如果你不改变路径,你总是会得到同样的结果。