Particle Class
Particle is a abstract entity with a small set of attributes such as position and color that ultimately dictate the particle's behavior and appearance. This class is a base class for classes, whih are used to create particles.
Item Index
Methods
Properties
Attributes
Events
Methods
alive
()
Check if particle is a live.
draw
canvas
Method draw defines action whithin onDraw. This method can be overwriten to customize particle appearance.
Parameters:
-
canvas
Canvascanvas used to draw graphics
Example:
// owerwrite ancestor's draw function
function draw(canvas)
{
// set bitmap translate acording to actual particle position
this._matrix.translateX = this._position.x;
this._matrix.translateY = this._position.y;
canvas.drawBitmapMatrix(MyParticle.img, this._matrix, MyParticle.paint);
}
init
() protected
Init instance. The init method sets all needed fields properties acording to developer requirements or to default values. This method is called when field object is constructed.
move
()
Method to move particle based on acceleration and velocity vector.
submitToFields
fields
This function affect particle's movement by a force fields.
Parameters:
-
fields
ArrayArray of Field
Properties
position
Vector
Location of the particle center.
Example:
// owerwrite ancestor's draw function
function draw(canvas)
{
// set bitmap translate acording to actual particle position
this._matrix.translateX = this._position.x;
this._matrix.translateY = this._position.y;
// draw custom particle bitmap
canvas.drawBitmapMatrix(MyParticle.img, this._matrix, MyParticle.paint);
}
velocity
Vector
Velocity vector of the particle. The initial velocity is given to the particle, when it is emitted from emitter.