Skscene class
| Inherit from |
SKEffectNode:SKNode:UIResponder:NSObject |
| Meet |
Nscoding (Sknode)
Nscopying (Sknode)
NSObject (NSObject) |
| Framework |
/system/library/frameworks/spritekit.framework |
| Availability of |
Available for iOS 7.0 or later |
| Declared on |
SKScene.h |
| Reference Guide |
Sprite Kit progamming Guide |
Overview
| Important: This is a preliminary API or development technical documentation. Although the technical accuracy of this document has been reviewed, it is not the final version. This confidential information applies only to registered members of the Apple developer program. Apple provides these confidential information to help you adopt these technologies and programming interfaces. If this information is changed, the software implemented in accordance with this document shall be tested using the operating system software and final documentation. New versions of the documentation may have new APIs or technologies. |
A Skscene instance represents a scene in a game. A scene node is usually the root node in the node tree. The other nodes in the node tree are responsible for providing the game content, and the scene node is responsible for rendering and displaying. To display a scene, you need to present it into a skview instance.
A scenario calculates the content using the following processing
1. Scene call Update: Method.
2. The scene performs the actions of its child nodes.
3. The scene calls the Didevaluateactions method.
4. The scene performs a physical simulation of the physical body added to the scene.
5. The scene calls the Didsimulatephysics method.
Sub-class nodes
Sometimes subclasses of the scene class are created. In the subclass scenario, the content of the scene sub-category and the execution logic are to be created.
Method
Initialize a scene
Creates and returns a new instance of the scene.
+ (Skscene *) Scenewithsize: (cgsize) size
| Parameters |
Size: Dimensions of the scene |
| return value |
A new instance of the scene |
Discussed
This class method creates a new scene and invokes its initwithsize: method to initialize the scene.
Initializes a new instance of the scene.
-(ID) initwithsize: (cgsize) size
| Parameters |
Size: Dimensions of the scene |
| return value |
A new, well-initialized scenario instance |
Discussed
This is the initialization method specified by the class method.
Changing the coordinate system of views and scenes
Turns the view coordinate system into a scene coordinate system.
-(Cgpoint) Converpointfromview: (cgpoint) point
| Parameters |
Point: A dot in the view coordinate system |
| return value |
The position of this point in the scene coordinate system |
Discussed
Before calling the method, the scene must already be added to the view.
Turn the scene coordinate system into a view coordinate system.
-(Cgpoint) Converpointtoview: (cgpoint) point
| Parameters |
Point: A dot in the scene coordinate system |
| return value |
The position of this point in the view coordinate system |
Discussed
Before calling the method, the scene must already be added to the view.
Change the size of the scene
This method is called when the scene size has changed.
-(void) Didchangesize: (cgsize) oldsize
| Parameters |
Oldsize: The original size of the scene |
| return value |
|
Discussed
This method is usually overridden by the quilt class.
Detects pop-up changes in the scene.
This method is called before the scene moves out of view.
-(void) Willmovefromview: (Skview *) view
| Parameters |
View: Views that hold the scene |
| return value |
|
Discussed
This method is usually overridden by the quilt class.
This method is called after the scene bounces to the view.
-(void) Didmovetoview: (Skview *) view
| Parameters |
View: Views that hold the scene |
| return value |
|
Discussed
This method is usually overridden by the quilt class.
Performing animation loops
The update that needs to be performed before the action in the scene executes.
-(void) Update: (nstimeinterval) currenttime
| Parameters |
CurrentTime: The time has elapsed, guaranteed monotonically increasing |
| return value |
|
Discussed
Do not call this method directly, when the scene is added to the view, and it is not paused, it is called once per frame. Your scene subclass should override this method and perform some required updates.
An update that needs to be performed after the action is executed in the scene.
-(void) didevaluateactions
Discussed
Do not call this method directly, when the scene is added to the view, and it is not paused, it is called once per frame. Your scene subclass should override this method and perform some required updates.
Updates that need to be performed after the physical simulation is executed.
-(void) didsimulatephysics
Discussed
Do not call this method directly, when the scene is added to the view, and it is not paused, it is called once per frame. Your scene subclass should override this method and perform some required updates.
Property
Viewing View-related properties
The position of the scene origin in the view.
@property (atomic) Cgpoint Anchorpoint
Discussed
Specifies the coordinate position of the scene. The default value is (0,0), which indicates that the scene is in the lower-left corner of the view rectangle.
Defines how the scene is mapped to the view.
@property (atomic) Skscenescalemode ScaleMode
Discussed
It is possible that the size of the scene is different from the size of the view it comes out of. This property defines how the scene is mapped to the view. See the scene Scaling modes section for detailed values. The default value is Skscenescalemodefill.
The view in which the scene is located. Read-only.
@property (Atomic, weak, ReadOnly) Skview *view
Discussed
To pop the scene, you need to call the Skview class's Presentscene: Method or Presentscene:transition: method.
Set the background color of the scene
The background color of the scene.
@property (Atomic, retain) Skcolor *backgroundcolor
Discussed
The default value is a gray color value (rgba0.15,0.15,0.15,1.0).
Change the size of the scene
The size of the scene.
@property (atomic) cgsize *size
The physical world running in the scene
The physical world in the scene.
@property (Atomic, readonly) Skphysicsworld *physicsworld
Discussed
All scenarios automatically simulate the physical characteristics of the nodes that add physical bodies. This property allows you to obtain the global physical properties of the scene, such as the gravitational acceleration.
Constant
Determine the popup mode of the scene
typedef ns_enum (Nsinteger,
Skscenescalemode) {
Skscenescalemodefill,
Skscenescalemodeaspectfill,
Skscenescalemodeaspectfit,
Skscenescalemoderesizefill
}
| Skscenescalemodefill |
Each axis of the scene is scaled independently, and the scene is fully mapped to the view |
| Skscenescalemodeaspectfill |
Each axis in the scene uses the same zoom factor to ensure that the view is fully populated and the scene may be clipped |
| Skscenescalemodeaspectfit |
Each axis in the scene uses the same zoom factor to ensure that the entire scene is visible |
| Skscenescalemoderesizefill |
Scene is not scaled, the scene is automatically resized to fit the view |
IOS--Skscene class