If SKShapeNode does not fit your need then you can use SceneKit directly. SpriteKit and SceneKit are aspects of the same thing. SpriteKit is for 2D sprites and SceneKit is for more complex 3D meshes. You can render 3D mesh content directly into your SpriteKit scene via SK3DNode
That should give you complete control over 3D meshes to make any effect you like.
So this effectively renders a SceneKit scene into a texture, and then draws that texture as a sprite in SpriteKit? How efficient is that method?
He doesn't understand your question, hence the tangential nature of the answer.
That 2D drawing exists in Cocos2D is a minor miracle.
Anyone from Apple, search for this, and consider it, it's true to its name, a very primitive type of 2D drawing this could be done much better if anyone was interested in providing dynamic drawing in 2D - I'm not posting a link because they get stuck waiting for needless approval:
Primitiveis added to support
Trianglesrendering. Previously, if we want to draw a custom geometry(sphere, line), we can only do this by using
CustomCommand. Now, what is need is to create a Primitive, set datas, and use the corresponding
PrimitiveCommandto draw the Primitive.
Most programmers of 2D games and game engines have no idea what animated 2D drawing is, and why animators considering designing games might want it, let alone how it might be used.
But the fault doesn't start there.
Once 3D became a thing, 2D optimisations and empowerment became a thing of the past, and all graphics hardware focused its efforts on 3D.
So there's no efficient way to do 2D drawing, and to do it well (with the kind of flexibility and dynamism you probably desire) requires someone to build an engine that constricts OpenGL triangle creation to a 2D plane and starts creating your drawings with triangles on that plane.
For that to then work for custom lines and animating them requires a lot more work, and is the subject of many interesting articles on how to then anti-alias these flat textured polygons in 2D space so they look like lines we're comfortable viewing.
Sound ridiculous? It is.
It gets funnier, of course. This problem has extended far outside realtime engines: Adobe's After Effects doesn't have decent 2D dynamic drawing either. Nodes (vertices) of a 2D drawing are not individually addressable, only editable in what amounts to an "analogue" manner.
Sprite Kit has SKShapeNode, which I'm sure you've found, but it's performance is barely even good enough for debugging physics bodies, and immutable. It was never intended to be a drawing facility in the sense you're asking about.
I'm not sure it's possible to articulate to a programmer how a desirable, truly flexible dynamic drawing facility should work in under 50 back and forth exchanges because they have odd misconceptions and are primarily against it because it's a technical nightmare and much work to make something truly great in terms of dynamic 2D drawing.
Interestingly, the same immutablity problem exists in Scene Kit's geometry creation facilities. They really don't care for dynamic geometry, let alone dynamic drawing.
My question is not related to free 2D drawing. I am perfectly aware of using OpenGL (or Metal) for emulating 2D games, which is what libraries like cocos2d and SpriteKit do, and its limitations.
My question was related to being able to define my own (textured) triangle meshes (either constricted to the 2D plane, or even 3D meshes). In cocos2d you could always do this in the past by writing OpenGL ES calls directly, and with the current version there's even direct support (which makes it more efficient by using batching, or something like that.)
When using an SK3DNode SceneKit draws directly into the same context, not to a texture.
To draw to a texture and use that as a sprite is another possible solution, but more cumbersome and less performant to using an SK3DNode.
I see. So SK3DNode is as efficient as it can possibly be. That's good to know. I suppose I'll have to learn SceneKit.