IOS--Skscene class

Source: Internet
Author: User

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

+ scenewithsize:

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.

-Initwithsize

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

-Convertpointfromview:

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.

-Convertpointtoview:

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

-Didchangesize:

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.

-Willmovefromview:

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.

-Didmovetoview:

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

-Update:

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.

-Didevaluateactions

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.

-Didsimulatephysics

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

Anchorpoint

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.

ScaleMode

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.

View

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

BackgroundColor

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

Size

The size of the scene.

@property (atomic) cgsize *size

The physical world running in the scene

Physicsworld

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.