Package | org.cove.ape |
Class | public class AbstractParticle |
Inheritance | AbstractParticle ![]() |
Subclasses | CircleParticle, RectangleParticle |
You should not instantiate this class directly -- instead use one of the subclasses.
Property | Defined by | ||
---|---|---|---|
![]() | alwaysRepaint : Boolean
For performance, fixed Particles and SpringConstraints don't have their
paint()
method called in order to avoid unnecessary redrawing. | AbstractItem | |
center : Vector
[read-only]
Returns A Vector of the current location of the particle
| AbstractParticle | ||
collidable : Boolean
Determines if the particle can collide with other particles or constraints.
| AbstractParticle | ||
elasticity : Number
The elasticity of the particle.
| AbstractParticle | ||
fixed : Boolean
The fixed state of the particle.
| AbstractParticle | ||
friction : Number
The surface friction of the particle.
| AbstractParticle | ||
mass : Number
The mass of the particle.
| AbstractParticle | ||
multisample : int
Determines the number of intermediate position steps checked for collision each
cycle.
| AbstractParticle | ||
position : Vector
The position of the particle.
| AbstractParticle | ||
px : Number
The x position of this particle
| AbstractParticle | ||
py : Number
The y position of this particle
| AbstractParticle | ||
![]() | sprite : Sprite
Provides a Sprite to use as a container for drawing or adding children.
| AbstractItem | |
velocity : Vector
The velocity of the particle.
| AbstractParticle | ||
![]() | visible : Boolean
The visibility of the item.
| AbstractItem |
Method | Defined by | ||
---|---|---|---|
Adds a force to the particle.
| AbstractParticle | ||
addMasslessForce(f:Vector):void
Adds a 'massless' force to the particle.
| AbstractParticle | ||
![]() |
cleanup():void
This method is called automatically when an item's parent group is removed
from the APEngine.
| AbstractItem | |
![]() |
init():void
This method is automatically called when an item's parent group is added to the engine,
an item's Composite is added to a Group, or the item is added to a Composite or Group.
| AbstractItem | |
![]() |
paint():void
The default painting method for this item.
| AbstractItem | |
setDisplay(d:DisplayObject, offsetX:Number = 0, offsetY:Number = 0, rotation:Number = 0):void
Assigns a DisplayObject to be used when painting this particle.
| AbstractParticle | ||
![]() |
setFill(color:uint = 0xffffff, alpha:Number = 1):void
Sets the style of the fill for this Item.
| AbstractItem | |
![]() |
setLine(thickness:Number = 0, color:uint = 0x000000, alpha:Number = 1):void
Sets the style of the line for this Item.
| AbstractItem | |
![]() |
setStyle(lineThickness:Number = 0, lineColor:uint = 0x000000, lineAlpha:Number = 1, fillColor:uint = 0xffffff, fillAlpha:Number = 1):void
Sets the line and fill of this Item.
| AbstractItem | |
update(dt2:Number):void
The
update() method is called automatically during the
APEngine.step() cycle. | AbstractParticle |
center | property |
center:Vector
[read-only]Returns A Vector of the current location of the particle
Implementation public function get center():Vector
collidable | property |
collidable:Boolean
[read-write]Determines if the particle can collide with other particles or constraints. The default state is true.
Implementation public function get collidable():Boolean
public function set collidable(value:Boolean):void
elasticity | property |
elasticity:Number
[read-write]The elasticity of the particle. Standard values are between 0 and 1. The higher the value, the greater the elasticity.
During collisions the elasticity values are combined. If one particle's elasticity is set to 0.4 and the other is set to 0.4 then the collision will be have a total elasticity of 0.8. The result will be the same if one particle has an elasticity of 0 and the other 0.8.
Setting the elasticity to greater than 1 (of a single particle, or in a combined collision) will cause particles to bounce with energy greater than naturally possible.
Implementation public function get elasticity():Number
public function set elasticity(value:Number):void
fixed | property |
fixed:Boolean
[read-write]The fixed state of the particle. If the particle is fixed, it does not move in response to forces or collisions. Fixed particles are good for surfaces.
Implementation public function get fixed():Boolean
public function set fixed(value:Boolean):void
friction | property |
friction:Number
[read-write]The surface friction of the particle. Values must be in the range of 0 to 1.
0 is no friction (slippery), 1 is full friction (sticky).
During collisions, the friction values are summed, but are clamped between 1 and 0. For example, If two particles have 0.7 as their surface friction, then the resulting friction between the two particles will be 1 (full friction).
In the current release, only dynamic friction is calculated. Static friction is planned for a later release.
There is a bug in the current release where colliding non-fixed particles with friction greater than 0 will behave erratically. A workaround is to only set the friction of fixed particles.
Implementation public function get friction():Number
public function set friction(value:Number):void
— ArgumentError if the friction is set less than zero or greater than 1
|
mass | property |
mass:Number
[read-write]The mass of the particle. Valid values are greater than zero. By default, all particles have a mass of 1. The mass property has no relation to the size of the particle.
Implementation public function get mass():Number
public function set mass(value:Number):void
— ArgumentError if the mass is set less than zero.
|
multisample | property |
multisample:int
[read-write]Determines the number of intermediate position steps checked for collision each cycle. Setting this number higher on fast moving particles can prevent 'tunneling' -- when a particle moves so fast it misses collision with certain surfaces.
Implementation public function get multisample():int
public function set multisample(value:int):void
position | property |
position:Vector
[read-write]The position of the particle. Getting the position of the particle is useful for drawing it or testing it for some custom purpose.
When you get the position
of a particle you are given a copy of the current
location. Because of this you cannot change the position of a particle by
altering the x
and y
components of the Vector you have retrieved from the position property.
You have to do something instead like: position = new Vector(100,100)
, or
you can use the px
and py
properties instead.
You can alter the position of a particle three ways: change its position, set its velocity, or apply a force to it. Setting the position of a non-fixed particle is not the same as setting its fixed property to true. A particle held in place by its position will behave as if it's attached there by a 0 length spring constraint.
Implementation public function get position():Vector
public function set position(value:Vector):void
px | property |
px:Number
[read-write]The x position of this particle
Implementation public function get px():Number
public function set px(value:Number):void
py | property |
py:Number
[read-write]The y position of this particle
Implementation public function get py():Number
public function set py(value:Number):void
velocity | property |
velocity:Vector
[read-write]The velocity of the particle. If you need to change the motion of a particle, you should either use this property, or one of the addForce methods. Generally, the addForce methods are best for slowly altering the motion. The velocity property is good for instantaneously setting the velocity, e.g., for projectiles.
Implementation public function get velocity():Vector
public function set velocity(value:Vector):void
addForce | () | method |
public function addForce(f:Vector):void
Adds a force to the particle. The mass of the particle is taken into account when using this method, so it is useful for adding forces that simulate effects like wind. Particles with larger masses will not be affected as greatly as those with smaller masses. Note that the size (not to be confused with mass) of the particle has no effect on its physical behavior with respect to forces.
Parametersf:Vector — A Vector represeting the force added.
|
addMasslessForce | () | method |
public function addMasslessForce(f:Vector):void
Adds a 'massless' force to the particle. The mass of the particle is not taken into account when using this method, so it is useful for adding forces that simulate effects like gravity. Particles with larger masses will be affected the same as those with smaller masses.
Parametersf:Vector — A Vector represeting the force added.
|
setDisplay | () | method |
public function setDisplay(d:DisplayObject, offsetX:Number = 0, offsetY:Number = 0, rotation:Number = 0):void
Assigns a DisplayObject to be used when painting this particle.
Parametersd:DisplayObject |
|
offsetX:Number (default = 0 )
|
|
offsetY:Number (default = 0 )
|
|
rotation:Number (default = 0 )
|
update | () | method |
public function update(dt2:Number):void
The update()
method is called automatically during the
APEngine.step() cycle. This method integrates the particle.
dt2:Number |