Sprite Kit - SKShapeNode Path Not Draw Square Curve

I delved into the new Apple Sprite Kit and used it for a while. However, I ran into a problem while trying to draw a curved path for SKShapeNode . It seems to be just a straight line.

Here is a very simple example of the problem I'm experiencing - experimenting with a CGPath drawing for SKShapeNode :

  CGMutablePathRef path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, 0, 0); CGPathAddQuadCurveToPoint(path, NULL, 50, 100, 100, 0); CGPathAddLineToPoint(path, NULL, 50, -100); CGPathCloseSubpath(path); SKShapeNode *shape = [[SKShapeNode alloc]init]; shape.path = path; [self addChild:shape]; CGPathRelease(path); 

Here is my ASCII art in what it does (sorry, I don't have enough reputation to post the actual image):

 --------------------------------------------------------------------------------- | EXPECTED RESULT | ACTUAL RESULT | --------------------------------------------------------------------------------- | | | | __----__ | | | / \ <- Curve | ? | | / \ | ____________ | | \ / | \ / | | \ / | \ / | | \ / | \ / | | \ / | \ / | | \ / | \ / | | \/ | \/ | --------------------------------------------------------------------------------- 

As you can see, it does not draw the curve I want from this line of code:

 CGPathAddQuadCurveToPoint(path, NULL, 50, 100, 100, 0); 

I tried using CGPathAddArcToPoint(...) , which works, and would be a good help in this example. However, for my real needs, I need to be able to draw an ATV.

It seems that CGPath draws everything except CGPathAddQuadCurveToPoint(...) , as well as CGPathAddCurveToPoint(...) - where they simply draw a straight line between the points.

Does anyone know what the problem is? Or is this a bug with the Sprite Kit?

+31
ios sprite-kit skshapenode cgpath
Jan 22 '14 at 21:44
source share
1 answer

That "y" should be the height of your curve, try giving it a non-zero value. Giving the coordinate, she cannot know how steep the curve should be. So this is the height

 CGPathAddQuadCurveToPoint(path, NULL, 50, 100, 100, 30); 
+2
Nov 13 '14 at 15:27
source share



All Articles