IOS--Skphysicsworld class

Source: Internet
Author: User

Skphysicsworld class
Inherit from NSObject
Meet Nscoding
NSObject (NSObject)
Framework /system/library/frameworks/spritekit.framework
Availability of Available for iOS 7.0 or later
Declared on SKPhysicsWorld.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.

Skphysicsworld instances simulate collisions and other physical properties. You do not need to create the Skphysicsworld property directly, you can view the Physicsworld property of Skscene.

Skphysicsworld instances allow you to do the following:

Simulates a global property, such as Gravity
Create a union between two physical bodies
Set up a proxy that receives messages between two connected physical bodies
Determine the intersection of points, rectangles, and rays between physical bodies

Method

Unite the physical body together.

-Addjoint:

Add a union to the physical world.

-(void) Addjoint: (Skphysicsjoint *) joint

Parameters Joint: The Union to be added
return value

Discussed

A union has to work, and it has to be added to the physical world.

-Removealljonits

Removes all unions in the physical world.

-(void) removealljoints

-Removejonit:

Removes the specified union from the physical world.

-(void) Removejoint: (Skphysicsjoint *) joint

Parameters Joint: the Union to be removed
return value

Find physical bodies in the physical world

-Bodyalongraystart:end:

Finds the first physical body that intersects the ray.

-(Skphysicsbody *) Bodyalongraystart: (cgpoint) Start end: (cgpoint) End

Parameters Start: The starting point of the Ray
End: The ending point of the Ray
return value The first physical body that intersects the ray, if not, returns nil

-Bodyatpoint:

Finds the first physical body that contains a point.

-(Skphysicsbody *) Bodyatpoint: (cgpoint) point

Parameters Point: A dot in the scene coordinate system
return value The first physical body containing this point, if not, returns nil

-Bodyinrect

Finds the first physical body that intersects the specified rectangle.

-(Skphysicsbody *) Bodyinrect: (cgrect) rect

Parameters Rect: A rectangle in the scene coordinate system
return value The first physical body that intersects with this rectangle, if not, returns nil

-EnumerateBodiesAlongRayStart:end:usingBlock:

Enumerates all the physical bodies that intersect the ray.

-(void) Enumeratebodiesalongraystart: (cgpoint) Start end: (cgpoint) End Usingblock: (void (^) (Skphysicsbody *body, Cgpoint poing, Cgpint Normal, BOOL *stop) block

Parameters Start: The starting point of the Ray
End: The ending point of the Ray
Block: A block of syntax, each of the physical bodies that intersect the ray will trigger
Body: The physical body that intersects the Ray
Point: The intersection of a ray and a physical body
Normal: normal vector at intersection
Stop: A Boolean value that terminates the enumeration
return value

-Enumeratebodiesatpoint:usingblock:

Enumerates all the physical bodies that contain a point.

-(void) Enumeratebodiesatpoint: (cgpoint) point usingblock: (void (^) (skphysicsbody *body, BOOL *stop)) block

Parameters Point: Points in the scene coordinate system
Block: A block of syntax that triggers every physical body that contains that point
Body: The physical body where the rays intersect
Stop: A Boolean value that terminates the enumeration
return value

-Enumeratebodiesinrect:usingblock:

Enumerates all the physical bodies that intersect the specified rectangle.

-(void) Enumeratebodiesinrect: (cgrect) rect usingblock: (void (^) (skphysicsbody *body, BOOL *stop)) block

Parameters Rect: A rectangle in the scene coordinate system
Block: A syntax block that fires every physical body that intersects with the rectangle.
Body: The physical body that intersects with the rectangle
Stop: A Boolean value that terminates the enumeration
return value

Property

Simulating the physical world

Gravity

A vector that specifies the gravitational acceleration of the physical world.

@property (atomic) Cgpoint Gravity

Discussed

The unit of this property is meters per second, and the default value is (0.0,-9.8), which represents the Earth's gravitational acceleration.

Speed

The execution rate of the simulation.

@property (atomic) CGFloat speed

Discussed

The default value is 1.0, which indicates that impersonation is performed at a normal rate. A value different from the default value will change the execution rate of the simulation. For example, a value of 2.0 indicates that the simulation will be performed at twice times the rate. If only 0.0, the tentative simulation is indicated.

Detects collisions in the physical world.

Contactdelegate

An agent that will be called when two connected bodies come in.

@property (Atomic, assign) id<skphysicscontactdelegate> contactdelegate

Discussed

When two physical bodies overlap, the connection is created. A physical body that owns the Contacttestbitmask attribute overlaps with the categorybitmask attribute of another physical body.

IOS--Skphysicsworld 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.