Ivan Lesko
Ivan Lesko

Reputation: 1304

What's the difference between SKView and SKScene

From the Apple Docs..

SKView: "An SKView object is a view that displays Sprite Kit content. This content is provided by an SKScene object."

SKSCene: "An SKScene object represents a scene of content in Sprite Kit."

What's the difference? Is an SKScene similar to a view controller and an SKView like a UIView?

Upvotes: 8

Views: 3312

Answers (1)

CodeSmile
CodeSmile

Reputation: 64477

The SKView is a UIView subclass. It wraps up Sprite Kit content in a view that can be used like any other Cocoa view. It usually has an associated view controller. That's Sprite Kit's connection with the Cocoa world.

The scene is the root object of the scene graph. It provides callbacks (physics, scene change, update) needed to implement a game. It does not concern itself with anything Cocoa related.

Normally the view remains as is while you can present scenes to swap out game content, for example moving from the menu to the game scene. Internally the view also caches resource files in memory, so as you switch scenes they don't have to reload the same textures.

Upvotes: 9

Related Questions