Why can't I add a SKScene to another SKScene?

荒凉一梦 提交于 2019-12-05 22:21:58

Can anyone tell me where I've gone wrong, and how I can fix it?

From the Overview section of the SKScene reference page:

A scene is the root node in a tree of Sprite Kit nodes (SKNode).

Since a tree can have only one root, any SKNode graph has just one scene.

To fix the problem, either use an SKNode (that's not a SKScene, obviously) to contain your end of game display. You can then add that node to your existing scene.

Imagine Scene as separate part of your application. Scenes differ by their function, for example you can have a main menu scene, a high scores scene, a gameplay scene, a credits scene.
Each of them is very different from the other. Scene is complete entity, it holds everything that you may want from it. You do not nest scenes.

What you want to do can be accomplished with SKNode or SKSpriteNode. Just create new node and add it to your scene. Move it to some far away coordinates (like 10000, 10000).

When you want to show it just change the coordinates to your needed ones.

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