03. node tree of sprite_kit foresight, 03. sprite_kit foresight
Sprite Kit prospective node tree
This article is only a forward looking. You only need to read it with appreciation.
SKSceneClass inherited fromSKNodeClass,SKNodeClass inherited fromUIResponderClass. After talking about the inheritance relationship, let's talk about nodes (Node), When we useSprite KitThe node is the basic building block of all content, and the scenario (sceneObjects Act as node treesRoot NodeRole. The scene and its descendants determine what to draw and how to render it.
In the coordinate system defined by the parent class, the positions of each node are clearly defined. At the same time, a node also applies to other attributes to its own content and its descendant content. For example, when A node is rotated, all its descendants will be rotated. This is easy to understand: for example, an object A acts as the parent class and has several attributes, B inherits A and naturally owns those attributes. However, if Object C inherits B, C will also have several attributes of A because of the inheritance relationship! What is the purpose? For example, we create a compleximageNode (nodeBy adjusting the node attributes on it to rotate, scale, and mix the entire image.
Emphasize:SkNodeClass does not draw anything, but it can pass its own attributes to its descendants. InSprite KitIn the framework, each type of printable content is represented by a specific subclass. Other nodes adjust their attributes to modify their descendants even if they do not draw content. For example, you can useSKEffectNodeClass adds an image filter function to inherit from itsSKSceneClass has this function. By precisely controlling the node tree structure, you can clearly control the node Rendering sequence.
Said,SKNodeClass inherited fromUIResponderOrNSResponderTherefore, as long as it is inherited fromSKNodeAll new classes of the class can receive user input. View (View) Class automatically extends the response chain to add nodes to the node tree of the scenario.
Supplement:
1. What are inherited fromSKNode?
SKLabelNode,SKLightNode,SKSpriteNode,SKVideoNodeAnd so on. View nameLabelIt is used to draw labels,VideoIt is naturally used to draw videos. Is there a feeling of having different jobs? In other words, every kind of things has a different class to draw, and they all inherit fromSKNode.