0

I try to bind SKShapeNode to CGPathGetCurrentPoint of my circle. But it seems that path is not moving.

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

 arc = [SKShapeNode node];
 arc.path = myPath;
...
[self  addChild:arc];

Here everything is OK. Then I connect my ball to the arc

ball = [SKShapeNode node];
ball.path = ballPath.CGPath;
[self addChild:ball];
...
d = CGPathGetCurrentPoint(arc.path);
 ball.position =  CGPointMake(d.x, d.y);

In touchesMoved I placed rotating code for my arc

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

And nothing happens. I want ball attach to arc current point and move with it.

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
  • what is angleRadians set to? and have you actually instantiated the ball node somewhere in your code? – user2277872 Feb 18 '14 at 15:16
  • When I run the app everything is OK. Ball placed on the right position. But when I rotate the arc ball stay on the previous position and don't follow arc currentPoint. it's seems like the path don't move. I don't understand what it is. – user3323877 Feb 18 '14 at 15:41
  • @user2277872 I tested differnt variations and now I exactly know that the path don't move. Because when I added a line my ball changed position. But don't rotate with arc. Any ideas? – user3323877 Feb 18 '14 at 18:54
  • I don't think the shape node will change when you change the contents of the CGPath, you'd have to re-assign or perhaps even create a new version of the CGPath and assign it again if you want the shape node to change its shape. – CodeSmile Feb 19 '14 at 09:26
  • It seems that you are mistaken on what makes `CGPathGetCurrentPoint`. `CGPathGetCurrentPoint` return the last point added to the path. So if you don't change the path, you will always get the same result. – Emmanuel Feb 19 '14 at 09:48
  • @LearnCocos2D Maybe you know how I can redraw new CGPath from SKShapeNode? – user3323877 Feb 19 '14 at 17:57

0 Answers0