Emitter Reference
See Particle Engine to know how to add particle emitters to the game.
Attributes
- position: array [x,y,z], example: [16,0,0] or ["RANDOMSCREENX","RANDOMSCREENY",100], define a relative pixel offset at which the particles are emitted, with special values RANDOMSCREENX and RANDOMSCREENY emitting at a random position of the screen
- relative: boolean, if true then the particles move with the player/object
- screenwrap: boolean, if true then the particles are placed on the other side of the screen when the particles move out of the screen (or the player moves), can be used for weather effects
- interval: number, example: 0.2, time between automatic emissions, in seconds
- quantity: number or array, example: 5 or [5,10], how many particles are emitted at once, you can specify a range
- reduceonmobile: boolean, if false then it will increase or decrease the particle count based on screen size (screen size divided by 1024/768 pixels)
- limit: number, limits the count of particles existing at the same time
- draworder: string, "up" or "down", down means oldest particle is drawn first, up means the newest particle is drawn first
- sound: string or array , example: ["crack"], plays a random sound from the array when emitted
- soundchance: number, example: 10, percentage of chance when the sound should be played
- particles: array of Particle
- tiletypes: array, example: [5, 6] (which is water and shallow water), only emits the particles on certain tiletypes, requires a tiletypes map layer, only works if "relative" is false
- ambient: array - example [0, 0.8], defines an ambient range between 0 and 1 in which the emitter should be active, the ambient value is the average of the current red, green and blue ambient colors
Particle
Particle templates which can be used in emitter.particles:
- lifetime: number or array, example: [0.9,1.3], number of seconds the particle is shown
- image: string, example: "bbuilder_snowflake.png", the particle image, file name from /Files/images/
- mode: string, example: "add", defines the blend mode: "add" added as "light effect", "subtract" for dark effects, otherwise "normal"
- alpha: number or array, example: 1, transparency of the image
- zoom: number or array, example: [0.25, 0.35], start scale factor of the particle
- red: number or array, example: [0.6, 1], start redness, in range of 0..1
- green: number or array, example: [0.6, 1], start greenness, in range of 0..1
- blue: number or array, example: 1, start blueness, in range of 0..1
- rotation: number or string or array, example: [0, 360], start rotation of the image, in range of 0..360 degrees, can be "OBJECT" for using the object rotation, is affected by spin
- spin: number or array, example: [-0.15, -0.05], change of rotation per second
- angle: number or array, example: 3.14, movement angle of the particle, 0..6.283, 0 is right, 1.57 is up
- speed: number or array, example: [15,20], in pixels, the particle is moved by Math.cos(angle) * speed, -Math.sin(angle) * speed
- zangle: number, example: -100, the "vertical speed", the particle is moved down (z axis), influenced by gravity
- gravity: number, example: 0, reduces zangle
- emitatend: number or array or array of arrays, example: 2, emit another particle if lifetime of particle is over, can be a single emitter, an array of 4 arrays (one for each direction of the object) or just an array of emitter names
- effects: array, example: [{"type":"range", "time":[0.5,1], "attr":"alpha", "mode":"replace", "value":[1,0.5]}]
Effect
Effects which can be specified in particle.effects:
- type: string, must be "range"
- time: array, example: [0.5,1], time range in which the effect should be applied to the particle
- attr: string, example: "alpha", which particle attribute to influence
- mode: string, must be "replace"
- value: array, example [1,0.5], start and end value of the attribute, can be used to change alpha from 1 to 0.5 in the specified time range