Constructor
new module:Particles(positionDefinition, base, generatoropt, updateropt, optionsopt)
Particles constructor
Name | Type | Attributes | Description |
---|---|---|---|
positionDefinition | PositionDefinition | Origin for all particles | |
base | Component | Blueprint for each particle | |
generator | OptionsGenerator | <optional> | Initialization function for all particles data |
updater | ParticlesCallback | <optional> | Function called on each particle draw (should not be computation intensive) |
options | ParticleOptions | <optional> |
Extends
Members
(static) defaultData :ParticleData
- ParticleData
(static) defaultOptions :ParticleOptions
- ParticleOptions
Methods
(static) from(definition) → {Particles}
Name | Type | Description |
---|---|---|
definition | Object | Particles definition |
- Type:
- Particles
generate(number, …params) → {Particles}
Create new particles
Name | Type | Attributes | Description |
---|---|---|---|
number | Number | Number of particles to generate | |
params | * | <repeatable> | Additional parameters for the generator function |
Itself
- Type:
- Particles
Type Definitions
OptionsGenerator(index)
Name | Type | Description |
---|---|---|
index | Number | Index of the particle |
ParticleData
ParticleData
- Object
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
position | Position | <optional> | new Position() | Position of the particle |
rotation | Number | <optional> | 0 | Rotation applied to the particle |
scale | Number | | <optional> | 1 | Scaling ratio or a pair of value for horizontal and vertical scaling |
ttl | Number | <optional> | Time to live, number of frames the particle is displayed. This number will be decremented and the data removed when it reach 0 |
ParticleOptions
- Object
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
frequency | Number | <optional> | 1 | Frequency of emission (randomized) |
emit | Number | | <optional> | Number or range of particles emitted | |
args | Array | <optional> | Arguments passed to the generator function |
ParticlesCallback(data, index, …params)
Name | Type | Attributes | Description |
---|---|---|---|
data | ParticleData | One particle data | |
index | Number | Index of the particle | |
params | * | <repeatable> | Additional parameters |