linearGravityField(direction:)
Creates and returns a field behavior object that models a linear gravitational force.
Declaration
class func linearGravityField(direction: CGVector) -> SelfParameters
- direction:
The vector indicating the direction of the gravitational force. You can change this value later by modifying the Direction property.
Return Value
A field behavior object that applies a directional gravitation force to items with mass.
Discussion
This field creates a directional gravitational force that applies uniformly to all dynamic items with mass. When setting the strength of the field, positive values attract items in the direction of the vector and negative values repel items. The force on a given item can be determined by the equation F = ma, where force equals the mass of the item multiplied by the acceleration imposed by the gravitational field, which with this type of field is constant.