ios sprite-kit cgpath skshapenode

ios - Sprite Kit-SKShapeNode Ruta que no dibuja Quad Curve



sprite-kit cgpath (1)

He estado profundizando en el nuevo Kit de Sprite de Apple, y lo he estado usando desde hace un tiempo. Sin embargo, me encontré con un problema al tratar de dibujar una ruta curva para un SKShapeNode . Simplemente parece dibujar una línea recta en su lugar.

Aquí hay un ejemplo muy simple del problema que estoy teniendo: experimentar dibujando un CGPath para un 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);

Aquí está mi arte ASCII de lo que está haciendo (lo siento, aún no tengo la reputación suficiente para publicar una imagen real):

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

Como puede ver, no está dibujando la curva que quiero de esta línea de código:

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

He intentado usar CGPathAddArcToPoint(...) , que funciona, y sería un buen sustituto en este ejemplo. Sin embargo, para mis necesidades reales, necesito poder dibujar una curva cuádruple.

El CGPath parece dibujar todo apropiadamente aparte de CGPathAddQuadCurveToPoint(...) y también, CGPathAddCurveToPoint(...) - donde simplemente trazan una línea recta entre los puntos.

¿Alguien tiene alguna idea de cuál es el problema? ¿O es esto un error con Sprite Kit?


Esa "y" debe ser la altura de tu curva, intenta darle un valor distinto de cero. Al dar una coordenada no puede saber qué tan pronunciada debe ser la curva. Así que esa es la altura.

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