ig.

Particle

new Particle()

Base entity class for particles.
- by default, particles do not collide with other entities
- by default, particles collide with collision map IMPORTANT: this is an abstract entity that should be extended.

Author:
  • Collin Hover - collinhover.com
  • Dominic Szablewski
  • Jesse Freeman
Source:
Example
// by default, the abstract particle looks for a set of animations
// to use as the current animation based on various properties
// the set is controlled by the animsExpected property
particle.animsExpected = [ "move" ];
// this behavior can be skipped using the "animAutomatic" property
particle.animAutomatic = false;
// the actual animation switching is done in the updateCurrentAnim method
// for example, the particle is expected to always be in motion
// so the current animation is set to move
particle.currentAnim = particle.getDirectionalAnimName( "move" );
// note here the directional animation name
// animations in Impact++ are directional and based on flip and facing
// so if an entity can flip X and Y
// you should have animations for both X and Y
// i.e. "moveX" and "moveY"
// if an entity cannot flip X and Y
// you should have animations for Up, Down, Left, and Right
// i.e. "moveUp", "moveDown", "moveLeft", "moveRight"

animAutomatic :Boolean

Whether entity is allowed to set own ig.EntityExtended#currentAnim automatically based on current state.

Source:
See:

animsExpected :Array

List of names of animations this entity is expected to have. IMPORTANT: when any animation in this list is not present, it will be filled by a placeholder animation!

Source:

bounciness :Number

Particles have a high bounciness.

Default Value:
  • 0.6
Source:

collisionKills :Boolean

Whether particle should kill self when hitting something.

Default Value:
  • false
Source:

collisionSticky :Boolean

Whether particle should stick to the first thing it collides with.

Default Value:
  • false
Source:

fadeAfterSpawnDuration :Number

Duration from birth at which particle will be fully faded in.

Default Value:
  • 0
Source:

fadeBeforeDeathDuration :Number

Duration from death at which particle will start to fade out.

Default Value:
  • 0.5
Source:

friction

Default Value:
  • 20 x 0
Source:

lifeDuration :Number

Total time from birth until death.

Default Value:
  • 1
Source:

lifeTimer :ig.Timer

Timer used to count down life time.
- created on init

Source:

maxVel

Default Value:
  • 150x150
Source:

minBounceVelocity :Number

Particles always bounce.

Default Value:
  • 0
Source:

performance

Particle performance should allow for full collision map interaction.

Default Value:
  • dynamic
Source:

randomDoubleVel :Boolean

Whether to randomize velocity on either side of zero on initialize. IMPORTANT: this only works if the particle has a velocity above 0, via ig.EntityExtended#vel.

Default Value:
  • true
Source:

randomFlip :Boolean

Whether to randomize particle flip on initialize. IMPORTANT: this modifies ig.EntityExtended#flip.

Default Value:
  • true
Source:

randomVel :Boolean

Whether to randomize velocity on initialize. IMPORTANT: this only works if the particle has a velocity above 0, via ig.EntityExtended#vel.

Default Value:
  • true
Source:

size

Default Value:
  • 1x1
Source:

velocityFlip :Boolean

Whether to set particle flip based on velocity on init. IMPORTANT: this modifies ig.EntityExtended#flip.

Default Value:
  • true
Source:

zIndex

Particles should almost always be rendered above anything else.

Source:
See:

collideWith()

Handles result of particle colliding with another entity.
- kills particle if hits another entity based on ig.Particle#collisionKills
- sticks to entity collding with based on ig.Particle#collisionSticky

Source:

handleMovementTrace()

Handles result of checking particle against collision map.
- kills particle if hits collision map based on ig.Particle#collisionKills
- sticks to collision map based on ig.Particle#collisionSticky

Source:

initProperties()

Source:

pause()

Source:

placeholdAnims()

Ensures all expected animations are present. IMPORTANT: when an expected animation is missing, it is placeholded by the init anim or the current anim.

Source:

ready()

Called when particle added to game world.
- sets ig.Particle#lifeTimer
- randomizes velocity based on ig.Particle#randomVel and ig.Particle#randomDoubleVel
- randomizes flip based on ig.Particle#randomFlip

Source:

recordChanges()

Records changes and sets particle facing based on its velocity.

Source:

resetExtras()

Source:

unpause()

Source:

update()

Updates particle and handles particle fade in/out as well as automatic death.

Source:

updateCurrentAnim()

Updates the current animation and flip based on the direction of travel.

Source:

updateVisible()

Updates visible and current animation via ig.Projectile#updateCurrentAnim.

Source: