| Package | org.flintparticles.twoD.actions |
| Class | public class ApproachNeighbours |
| Inheritance | ApproachNeighbours ActionBase |
ApproachNeighbours is most commonly used when creating flocking behaviours. Flocking is usually a combination of ApproachNeighbours to draw particles together, MinimumDistance to stop them getting too close and MatchVelocity to make them match speed and direction of motion.
See also
| Property | Defined by | ||
|---|---|---|---|
| acceleration : Number
The acceleration applied to approach the other particles.
| ApproachNeighbours | ||
| maxDistance : Number
The maximum distance, in pixels, over which this action operates.
| ApproachNeighbours | ||
| Method | Defined by | ||
|---|---|---|---|
|
ApproachNeighbours(maxDistance:Number, acceleration:Number)
The constructor creates an ApproachNeighbours action for use by an emitter.
| ApproachNeighbours | ||
|
addedToEmitter(emitter:Emitter):void
Instructs the emitter to produce a sorted particle array for optimizing
the calculations in the update method of this action.
| ApproachNeighbours | ||
|
getDefaultPriority():Number
Returns a value of 10, so that the ApproachNeighbours action executes
before accelerating actions that act on particles independently of
other particles, like Acceleration and GravityWell.
| ApproachNeighbours | ||
![]() |
removedFromEmitter(emitter:Emitter):void
This method does nothing.
| ActionBase | |
|
Checks all particles near the current particle and applies the
acceleration to move the particle towards their average position.
| ApproachNeighbours | ||
| acceleration | property |
acceleration:Number [read-write]The acceleration applied to approach the other particles.
Implementation public function get acceleration():Number
public function set acceleration(value:Number):void
| maxDistance | property |
maxDistance:Number [read-write]The maximum distance, in pixels, over which this action operates. Particles further apart than this distance ignore each other.
Implementation public function get maxDistance():Number
public function set maxDistance(value:Number):void
| ApproachNeighbours | () | constructor |
public function ApproachNeighbours(maxDistance:Number, acceleration:Number)The constructor creates an ApproachNeighbours action for use by an emitter. To add an ApproachNeighbours to all particles created by an emitter, use the emitter's addAction method.
ParametersmaxDistance:Number — The maximum distance, in pixels, over which this action
operates. Particles further apart than this distance ignore each other.
|
|
acceleration:Number — The size of the acceleration applied to approach the
other particles.
|
See also
| addedToEmitter | () | method |
public override function addedToEmitter(emitter:Emitter):voidInstructs the emitter to produce a sorted particle array for optimizing the calculations in the update method of this action.
Parametersemitter:Emitter — The emitter this action has been added to.
|
See also
| getDefaultPriority | () | method |
public override function getDefaultPriority():NumberReturns a value of 10, so that the ApproachNeighbours action executes before accelerating actions that act on particles independently of other particles, like Acceleration and GravityWell.
ReturnsNumber |
See also
| update | () | method |
public override function update(emitter:Emitter, particle:Particle, time:Number):voidChecks all particles near the current particle and applies the acceleration to move the particle towards their average position.
This method is called by the emitter and need not be called by the user.
Parametersemitter: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