Packageorg.flintparticles.twoD.actions
Classpublic class Collide
InheritanceCollide Inheritance ActionBase
ImplementsFrameUpdatable

The Collide action detects collisions between particles and modifies their velocities in response to the collision. All particles are approximated to a circular shape for the collisions and they are assumed to be of equal density.

If the particles reach a stationary, or near stationary, state under an accelerating force (e.g. gravity) then they will fall through each other. This is due to the nature of the alogorithm used, which is designed for speed of execution and sufficient accuracy when the particles are in motion, not for absolute precision.



Public Properties
 PropertyDefined by
  bounce : Number
The coefficient of restitution when the particles collide.
Collide
Public Methods
 MethodDefined by
  
Collide(bounce:Number = 1)
The constructor creates a Collide action for use by an emitter.
Collide
  
addedToEmitter(emitter:Emitter):void
Instructs the emitter to produce a sorted particle array for optimizing the calculations in the update method of this action and adds an UpdateOnFrame activity to the emitter to call this objects frameUpdate method once per frame.
Collide
  
frameUpdate(emitter:Emitter, time:Number):void
Called every frame before the particles are updated, this method calculates the collision radius of the largest two particles, which aids in optimizing the collision calculations.
Collide
  
Returns a value of 10, so that the collide action executes before other actions that move teh particles independently of each other.
Collide
  
Removes the UpdateOnFrame activity that was added to the emitter in the addedToEmitter method.
Collide
  
update(emitter:Emitter, particle:Particle, time:Number):void
Causes the particle to check for collisions against all other particles.
Collide
Property detail
bounceproperty
bounce:Number  [read-write]

The coefficient of restitution when the particles collide. A value of 1 gives a pure elastic collision, with no energy loss. A value between 0 and 1 causes the particles to loose enegy in the collision. A value greater than 1 causes the particles to gain energy in the collision.

Implementation
    public function get bounce():Number
    public function set bounce(value:Number):void
Constructor detail
Collide()constructor
public function Collide(bounce:Number = 1)

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

Parameters
bounce:Number (default = 1) — The coefficient of restitution when the particles collide. A value of 1 gives a pure elastic collision, with no energy loss. A value between 0 and 1 causes the particles to loose enegy in the collision. A value greater than 1 causes the particle to gain energy in the collision.

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 and adds an UpdateOnFrame activity to the emitter to call this objects frameUpdate method once per frame.

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

See also

frameUpdate()method 
public function frameUpdate(emitter:Emitter, time:Number):void

Called every frame before the particles are updated, this method calculates the collision radius of the largest two particles, which aids in optimizing the collision calculations.

This method is called using an UpdateOnFrame activity that is created in the addedToEmitter method.

Parameters
emitter:Emitter — The emitter that is using this action.
 
time:Number — The duration of the current animation frame.

See also

getDefaultPriority()method 
public override function getDefaultPriority():Number

Returns a value of 10, so that the collide action executes before other actions that move teh particles independently of each other.

Returns
Number

See also

removedFromEmitter()method 
public override function removedFromEmitter(emitter:Emitter):void

Removes the UpdateOnFrame activity that was added to the emitter in the addedToEmitter method.

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

Causes the particle to check for collisions against all other particles.

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