SKSpriteNode gets hidden below parent node

时光总嘲笑我的痴心妄想 提交于 2019-12-05 08:17:41

What you're looking for is the ignoresSiblingOrder property on SKView:

A Boolean value that indicates whether parent-child and sibling relationships affect the rendering order of nodes in the scene.

The default Xcode 6.x (and maybe 5, I haven't checked) SpriteKit template sets that to true when setting up the SKView in the view controller. With it set to true, the order that you add nodes to the scene does not affect their z-position. If you set it to false, they'll be layered in the order you add them to the scene (or parent node).

That being said, SpritKit can do some optimizations when ignoresSiblingOrder is true (which is why that's the default in the template), so it's probably best to keep it that way if at all possible. In that case, you'll have to manually set the zPosition property of each node though.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!