SKFieldNode
A node that applies physics effects to nearby nodes.
Declaration
class SKFieldNodeMentioned in
Overview
There are many different kinds of field nodes that can be created, each with different effects. The SKFieldNode section lists the field types you can create using SpriteKit, including a type that allows you to apply custom forces to physics bodies. Instantiate the appropriate kind of field node and then add it to the scene’s node tree.
When the scene simulates physics effects, a field node applies its effect to a physics body so long as the following are true:
The field node is in the scene’s node tree.
The physics body is attached to a node that is in the scene’s node tree.
The physics body is located inside the field node’s region (see region).
The physics body is not located inside the region of another field node whose isExclusive property is set to true.
A logical AND operation between the field node’s categoryBitMask property and the physics body’s fieldBitMask property results in a nonzero value.
Topics
Getting Started with Field Nodes
Creating Field Nodes
dragField()electricField()linearGravityField(withVector:)magneticField()noiseField(withSmoothness:animationSpeed:)radialGravityField()springField()turbulenceField(withSmoothness:animationSpeed:)velocityField(with:)velocityField(withVector:)vortexField()customField(evaluationBlock:)SKFieldForceEvaluator