Packageorg.flintparticles.twoD.actions
Classpublic class MutualGravity
InheritanceMutualGravity Inheritance ActionBase

The MutualGravity Action applies forces to attract each particle towards the other particles. The force applied is inversely proportional to the square of the distance between the particles, in accordance with Newton's law of gravity. This simulates the effect of gravity over large distances (as between planets, for example).

This action has a priority of 10, so that it executes before other actions.



Public Properties
 PropertyDefined by
  epsilon : Number
The minimum distance for which the gravity force is calculated.
MutualGravity
  maxDistance : Number
The maximum distance between particles for the gravitational effect to be calculated.
MutualGravity
  power : Number
The strength of the gravity force.
MutualGravity
 Inheritedpriority : int
Returns a default priority of 0 for this action.
ActionBase
Protected Properties
 PropertyDefined by
 Inherited_priority : int = 0
ActionBase
Public Methods
 MethodDefined by
  
MutualGravity(power:Number = 0, maxDistance:Number = 0, epsilon:Number = 1)
The constructor creates a MutualGravity action for use by an emitter.
MutualGravity
  
addedToEmitter(emitter:Emitter):void
Instructs the emitter to produce a sorted particle array for optimizing the calculations in the update method of this action.
MutualGravity
 Inherited
This method does nothing.
ActionBase
  
update(emitter:Emitter, particle:Particle, time:Number):void
Checks all particles near the current particle and applies the gravity force between them.
MutualGravity
Property detail
epsilonproperty
epsilon:Number  [read-write]

The minimum distance for which the gravity force is calculated. Particles closer than this distance experience the gravity as it they were this distance away. This stops the gravity effect blowing up as distances get very small.

Implementation
    public function get epsilon():Number
    public function set epsilon(value:Number):void
maxDistanceproperty 
maxDistance:Number  [read-write]

The maximum distance between particles for the gravitational effect to be calculated. You can sometimes speed up the calculation of this action by reducing the maxDistance since often only the closest other particles have a significant effect on the motion of a particle.

Implementation
    public function get maxDistance():Number
    public function set maxDistance(value:Number):void
powerproperty 
power:Number  [read-write]

The strength of the gravity force.

Implementation
    public function get power():Number
    public function set power(value:Number):void
Constructor detail
MutualGravity()constructor
public function MutualGravity(power:Number = 0, maxDistance:Number = 0, epsilon:Number = 1)

The constructor creates a MutualGravity action for use by an emitter. To add a MutualGravity to all particles created by an emitter, use the emitter's addAction method.

Parameters
power:Number (default = 0) — The strength of the gravitational pull between the particles.
 
maxDistance:Number (default = 0) — The maximum distance between particles for the gravitational effect to be calculated. You can sometimes speed up the calculation of this action by reducing the maxDistance since often only the closest other particles have a significant effect on the motion of a particle.
 
epsilon:Number (default = 1) — The minimum distance for which gravity is calculated. Particles closer than this distance experience a gravity force as if they were this distance away. This stops the gravity effect blowing up as distances get small.

See also

Method detail
addedToEmitter()method
public override function addedToEmitter(emitter:Emitter):void

Instructs the emitter to produce a sorted particle array for optimizing the calculations in the update method of this action.

Parameters
emitter:Emitter — The emitter this action has been added to.

See also

update()method 
public override function update(emitter:Emitter, particle:Particle, time:Number):void

Checks all particles near the current particle and applies the gravity force between them.

This method is called by the emitter and need not be called by the user.

Parameters
emitter:Emitter — The Emitter that created the particle.
 
particle:Particle — The particle to be updated.
 
time:Number — The duration of the frame - used for time based updates.

See also