| Package | flare.physics |
| Class | public class Simulation |
| Property | Defined by | ||
|---|---|---|---|
| bounds : Rectangle Sets a bounding box for particles in this simulation.
| Simulation | ||
| dragForce : DragForce
[read-only] The default drag force for this simulation.
| Simulation | ||
| gravityForce : GravityForce
[read-only] The default gravity force for this simulation.
| Simulation | ||
| nbodyForce : NBodyForce
[read-only] The default n-body force for this simulation.
| Simulation | ||
| objectPoolLimit : int = 5000 [static] The maximum number of items stored in a simulation object pool.
| Simulation | ||
| particles : Array [read-only]
Returns the particle list.
| Simulation | ||
| springForce : SpringForce
[read-only] The default spring force for this simulation.
| Simulation | ||
| springs : Array [read-only]
Returns the spring list.
| Simulation | ||
| Property | Defined by | ||
|---|---|---|---|
| _ppool : Array [static]
| Simulation | ||
| _spool : Array [static]
| Simulation | ||
| Method | Defined by | ||
|---|---|---|---|
|
Simulation(gx:Number = 0, gy:Number = 0, drag:Number = 0.1, attraction:Number = -5)
Creates a new physics simulation.
| Simulation | ||
|
Adds a custom force to the force simulation.
| Simulation | ||
|
addParticle(mass:Number, x:Number, y:Number):Particle
Adds a new particle to the simulation.
| Simulation | ||
|
Adds a spring to the simulation
| Simulation | ||
|
eval():void
Evaluates the set of forces in the simulation.
| Simulation | ||
|
getForceAt(idx:int):IForce
Returns the force at the given index.
| Simulation | ||
|
removeParticle(idx:uint):Boolean
Removes a particle from the simulation.
| Simulation | ||
|
removeSpring(idx:uint):Boolean
Removes a spring from the simulation.
| Simulation | ||
|
tick(dt:Number = 1):void
Advance the simulation for the specified time interval.
| Simulation | ||
| Method | Defined by | ||
|---|---|---|---|
|
getParticle(mass:Number, x:Number, y:Number):Particle
[static]
Returns a particle instance, pulling a recycled particle from the
object pool if available.
| Simulation | ||
|
[static]
Returns a spring instance, pulling a recycled spring from the
object pool if available.
| Simulation | ||
|
reclaimParticle(p:Particle):void
[static]
Reclaims a particle, adding it to the object pool for recycling
| Simulation | ||
|
reclaimSpring(s:Spring):void
[static]
Reclaims a spring, adding it to the object pool for recycling
| Simulation | ||
| bounds | property |
bounds:Rectangle [read-write]Sets a bounding box for particles in this simulation. Null (the default) indicates no boundaries.
Implementation public function get bounds():Rectangle
public function set bounds(value:Rectangle):void
| dragForce | property |
dragForce:DragForce [read-only]The default drag force for this simulation.
Implementation public function get dragForce():DragForce
| gravityForce | property |
gravityForce:GravityForce [read-only]The default gravity force for this simulation.
Implementation public function get gravityForce():GravityForce
| nbodyForce | property |
nbodyForce:NBodyForce [read-only]The default n-body force for this simulation.
Implementation public function get nbodyForce():NBodyForce
| objectPoolLimit | property |
public static var objectPoolLimit:int = 5000The maximum number of items stored in a simulation object pool.
| particles | property |
particles:Array [read-only]Returns the particle list. This is the same array instance backing the simulation, so edit the array with caution.
Implementation public function get particles():Array
| _ppool | property |
protected static var _ppool:Array
| _spool | property |
protected static var _spool:Array
| springForce | property |
springForce:SpringForce [read-only]The default spring force for this simulation.
Implementation public function get springForce():SpringForce
| springs | property |
springs:Array [read-only]Returns the spring list. This is the same array instance backing the simulation, so edit the array with caution.
Implementation public function get springs():Array
| Simulation | () | constructor |
public function Simulation(gx:Number = 0, gy:Number = 0, drag:Number = 0.1, attraction:Number = -5)Creates a new physics simulation.
Parametersgx:Number (default = 0) — the gravitational acceleration along the x dimension
|
|
gy:Number (default = 0) — the gravitational acceleration along the y dimension
|
|
drag:Number (default = 0.1) — the default drag (viscosity) co-efficient
|
|
attraction:Number (default = -5) — the gravitational attraction (or repulsion, for
negative values) between particles.
|
| addForce | () | method |
public function addForce(force:IForce):voidAdds a custom force to the force simulation.
Parametersforce:IForce — the force to add
|
| addParticle | () | method |
public function addParticle(mass:Number, x:Number, y:Number):ParticleAdds a new particle to the simulation.
Parametersmass:Number — the mass (charge) of the particle
|
|
x:Number — the particle's starting x position
|
|
y:Number — the particle's starting y position
|
Particle —
the added particle
|
| addSpring | () | method |
public function addSpring(p1:Particle, p2:Particle, restLength:Number, tension:Number, damping:Number):SpringAdds a spring to the simulation
Parametersp1:Particle — the first particle attached to the spring
|
|
p2:Particle — the second particle attached to the spring
|
|
restLength:Number — the rest length of the spring
|
|
tension:Number — the tension of the spring
|
|
damping:Number — the damping (friction) co-efficient of the spring
|
Spring —
the added spring
|
| eval | () | method |
public function eval():voidEvaluates the set of forces in the simulation.
| getForceAt | () | method |
public function getForceAt(idx:int):IForceReturns the force at the given index.
Parametersidx:int — the index of the force to look up
|
IForce —
the force at the specified index
|
| getParticle | () | method |
protected static function getParticle(mass:Number, x:Number, y:Number):ParticleReturns a particle instance, pulling a recycled particle from the object pool if available.
Parametersmass:Number — the mass (charge) of the particle
|
|
x:Number — the particle's starting x position
|
|
y:Number — the particle's starting y position
|
Particle —
a particle instance
|
| getSpring | () | method |
protected static function getSpring(p1:Particle, p2:Particle, restLength:Number, tension:Number, damping:Number):SpringReturns a spring instance, pulling a recycled spring from the object pool if available.
Parametersp1:Particle — the first particle attached to the spring
|
|
p2:Particle — the second particle attached to the spring
|
|
restLength:Number — the rest length of the spring
|
|
tension:Number — the tension of the spring
|
|
damping:Number — the damping (friction) co-efficient of the spring
|
Spring —
a spring instance
|
| reclaimParticle | () | method |
protected static function reclaimParticle(p:Particle):voidReclaims a particle, adding it to the object pool for recycling
Parametersp:Particle — the particle to reclaim
|
| reclaimSpring | () | method |
protected static function reclaimSpring(s:Spring):voidReclaims a spring, adding it to the object pool for recycling
Parameterss:Spring — the spring to reclaim
|
| removeParticle | () | method |
public function removeParticle(idx:uint):BooleanRemoves a particle from the simulation. Any springs attached to the particle will also be removed.
Parametersidx:uint — the index of the particle in the particle list
|
Boolean — true if removed, false otherwise.
|
| removeSpring | () | method |
public function removeSpring(idx:uint):BooleanRemoves a spring from the simulation.
Parametersidx:uint — the index of the spring in the spring list
|
Boolean — true if removed, false otherwise
|
| tick | () | method |
public function tick(dt:Number = 1):voidAdvance the simulation for the specified time interval.
Parametersdt:Number (default = 1) — the time interval to step the simulation (default 1)
|