new ParticleEmitter(pos, rate, continuous, lifespan, sprite, rotation, spin, scale, opacity, range, velocity, events)
Create a new particle emitter.
Parameters:
Name | Type | Description |
---|---|---|
pos | Vec2 | Position of emitter |
rate | number | Seconds between spawning particles, or number to spawn (if continuous is false) |
continuous | boolean | Whether particles should be spawned repeatedly every [rate] seconds, or all at once |
lifespan | number | Lifespan of particles |
sprite | string | | Sprite or identifier of sprite to use for particles |
rotation | "random" | | Rotation of particles |
spin | number | Angular velocity of particles |
scale | number | | Scale of particles |
opacity | number | | Opacity of particles |
range | number | | Range of spawning particles |
velocity | number | | Velocity of particles (if a number is given, it will be outward from the source) |
events | Object | Events to add to emitter |
Extends
Members
collisionBounds
Get the total bounding box of all collision components.
- Overrides
- Source
components
Get the component manager.
- Overrides
- Source
drawableBounds
Get the total bounding box of all drawable components.
- Overrides
- Source
globalID
Get the global identifier.
- Overrides
- Source
globalPos
Get the global position.
- Overrides
- Source
initialized
Check if the actor has been initialized.
- Overrides
- Source
pos
Get the local position.
- Overrides
- Source
Methods
addAnimation(animation) → {ActorAnimation}
Add an animation.
Parameters:
Name | Type | Description |
---|---|---|
animation | ActorAnimation | Animation to add |
- Overrides
- Source
Returns:
Animation that was added
- Type:
- ActorAnimation
checkCollision(other, pos) → {Object}
Check collision with another actor.
Parameters:
Name | Type | Description |
---|---|---|
other | CollisionComponent | Other component to check with |
pos | Vec2 | The position to attempt to move to |
- Overrides
- Source
Returns:
Collision result
- Type:
- Object
clearChildren()
Remove and delete all child actors.
- Overrides
- Source
clearOverlappingChunks()
Clear and remove actor from all overlapping chunks.
- Overrides
- Source
delete()
Mark the actor for deletion.
- Overrides
- Source
doEvent(event, …args)
Run all functions attached to a specified event.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
event | ActorEvent | | Event to trigger | |
args | any | <repeatable> | Arguments to pass into functions |
- Overrides
- Source
draw(ctx)
Draw the actor
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | The canvas context to draw on |
- Overrides
- Source
drawDebug(ctx, showID, showDot)
Draw debug information for the actor (if enabled).
Parameters:
Name | Type | Default | Description |
---|---|---|---|
ctx | CanvasRenderingContext2D | Canvas context to draw on | |
showID | boolean | true | Whether to show chunk actor ID |
showDot | boolean | true | Whether to show the dot in the center |
- Overrides
- Source
findOverlappingChunks()
Find, save, and register in all chunks that collision components are overlapping with.
- Overrides
- Source
forEachChild(func)
Run a function for each child actor.
Parameters:
Name | Type | Description |
---|---|---|
func | function | Function to run for each child |
- Overrides
- Source
getTransformMatrix(trans, rot, scale)
Get the global transformation matrix.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
trans | boolean | true | Whether to include translation |
rot | boolean | true | Whether to include rotation |
scale | boolean | true | Whether to include scaling |
- Overrides
- Source
Returns:
Global transformation matrix
hasAnimations() → {boolean}
Check if there are any active animations.
- Overrides
- Source
Returns:
Whether any animations are active
- Type:
- boolean
hasParent() → {boolean}
Check if the actor has a parent actor.
- Overrides
- Source
Returns:
Whether actor has a parent
- Type:
- boolean
init()
Executed when an actor is added to a space.
- Overrides
- Source
on(event, func)
Add an event function.
Parameters:
Name | Type | Description |
---|---|---|
event | ActorEvent | | Event to add function to |
func | function | Function to run when called |
- Overrides
- Source
removeChild(actor)
Remove a child actor. This will delete the actor.
Parameters:
Name | Type | Description |
---|---|---|
actor | Actor | Child to remove |
- Overrides
- Source
resetShadow(ctx)
Reset/remove the shadow for drawing.
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Canvas context to draw on |
- Overrides
- Source
setParent(actor)
Set the parent actor (do not call this manually).
Parameters:
Name | Type | Description |
---|---|---|
actor | Actor | New parent actor. |
- Overrides
- Source
setShadow(ctx)
Set up the shadow for drawing.
Parameters:
Name | Type | Description |
---|---|---|
ctx | CanvasRenderingContext2D | Canvas context to draw on |
- Overrides
- Source
stopAnimations()
Stop all animations.
- Overrides
- Source
update(elapsed)
Update the actor
Parameters:
Name | Type | Description |
---|---|---|
elapsed | number | Time since last update |
- Overrides
- Source
Type Definitions
addChild
Add a child actor.
Type:
- Overrides
- Source