Sprite Kit – SKShapeNode Path not drawing Quad Curve

I have been delving in to Apple’s new Sprite Kit, and been using it for a while now.
However I ran into an issue when trying to draw a curved path for an SKShapeNode. It just appears to draw a straight line instead.

Here is a very simple example of the issue I am having – experimenting with drawing a CGPath for an SKShapeNode:

  • Is it possible to show a tooltip in an iOS app?
  • Swipe to delete on CollectionView
  • could NaN be causing the occasional crash in this core audio iOS app?
  • Does Apple reject apps that use images used in Apple's apps?
  • How to combine two UIImages of difference size without altering their original aspect ratios?
  • Xcode 7 SpriteKit Error with Blocks
  •     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 of what it is doing (Sorry I don’t have enough reputation to post an actual image yet):

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

    As you can see, it is not drawing the curve that I want from this line of code:

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

    I have tried using CGPathAddArcToPoint(...), which works, and would be a good substitute in this example. However, for my actual needs, I need to be able to draw a quad curve.

    The CGPath seems to be drawing everything appropriately apart from CGPathAddQuadCurveToPoint(...) and also, CGPathAddCurveToPoint(...) – where they just draw a straight line between the points instead.

    Does anyone have any idea what the issue is? Or is this a bug with Sprite Kit?

    Solutions Collect From Internet About “Sprite Kit – SKShapeNode Path not drawing Quad Curve”

    That “y” should be the height of your curve, try giving it a non zero value.
    By giving a coordinate it cannot know how steep the curve should be. So that is the height

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