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?
ios sprite-kit skshapenode cgpath
David Williames Jan 22 '14 at 21:44 2014-01-22 21:44
source share