简体   繁体   中英

Skscene within skscene

Is it possible to properly present a small scene within the standard, full-screen scene we get when working with SpriteKit? Since an SKScene is essentially a UIView, it should be possible no?

No. You can't have two scenes in one scene. A scene is similar to the root view controller . You can't have two root view controllers. Similarly you can't have two scenes. You can add as many nodes to the scenes as you can. They are all considered as the children of the scene ie you can add a simple view as a subview to the scene.

From the Documentation:

An SKScene object represents a scene of content in Sprite Kit. A scene is the root node in a tree of Sprite Kit nodes (SKNode).

Scenes are not UIViews, they have nothing to do with UIViews, and are only to be attached to an SKView for rendering purposes. As Mr.T pointed out, scenes are just SKNodes that act as a root node. You can add a scene to another scene via addChild, but nothing will happen, you will not get update to call twice or anything like that, it essentially becomes another SKNode.

If you need a little window to pop up, just create an SKNode, and throw children SKNodes inside of it to layout the window.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM