In Cocos2D we usually have one scene and then we can add layers on top of one another.Concept of layers is very handy as it helps organizing, moving and removing many nodes in groups. Now I need to perform the same thing in Sprite Kit, but can't find an equivalent to CCLayer. I tried adding my sprites on an SKNode and then add that node to my scene but what I got was an empty view. I can't believe it's not possible in Sprite Kit. Maybe it's not out of the box and I need to create my own layers? Any hint will be appreciated.

有帮助吗?

解决方案

A CCLayer is only just a node. There is no code added to CCLayer that makes it a "layer", it just happens to be a (unfitting) name for a non-visible node class that in addition to CCNode merely provides additional input callback methods. A better name for CCLayer would have been CCInputNode.

So any node, SKNode or CCNode, work perfectly for grouping ("layering") other nodes in cocos2d and Sprite Kit alike.

More precisely, CCNode/SKNode are THE layering nodes per se. All other classes inherit the fact that a node can have child nodes from the node base classes. The child nodes allow creating a tree of modes (the scene graph) and technically also allow any node to work as a grouping/layering instrument.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top