CreateParticle

Category: Particles
Since engine version: 3.4 OC

Description

Creates a new particle with the given properties. Note that particle creation is not necessarily synchronized over the network and thus, the return value is not whether the particle was actually created but whether the particle definition was found.

Syntax

bool CreateParticle(string particle_name, int x, int y, int speed_x, int speed_y, int lifetime, proplist properties, int amount);

Parameters

particle_name:
Name of the particle definition.
x:
X-coordinate of the new particle (relative to object for local calls).
y:
Y-coordinate of the new particle (relative to object for local calls).
speed_x:
Starting speed of the particle in x-direction. Can also be a value provider function.
speed_y:
Starting speed of the particle in y-direction. Can also be a value provider function.
lifetime:
Time in frames that the particle will be alive before it is removed. Can also be a value provider function. If set to 0, the particle will not be removed automatically.
properties:
PropList with the particle attributes (see the particle documentation).
amount:
Amount of particles to create. Defaults to 1.

Remark

See the particle documentation for further explanations.

Example

var particles =
{
	Size = PV_KeyFrames(0, 0, 0, 200, 50, 1000, 0),
	DampingX = 900,
	DampingY = 900,
	R = 255,
	G = PV_Linear(255, 0),
	B = PV_Linear(128, 0),
	Alpha = PV_Linear(255, 0),
	Rotation = PV_Direction(),
	Stretch = PV_Speed(5 * 1000),
	ForceY = PV_KeyFrames(0, 0, 0, 900, 0, 1000, -20),
	ForceX = PV_Random(-5, 5, 15),
	Phase = PV_Step(1, 0, 10)
};
CreateParticle("Fire", 0, 0, PV_Random(-200, 200), PV_Random(-200, 200), PV_Random(18, 38 * 5), particles, 100);
			
Casts 100 particles with a previously defined behavior.
See also: PC_Bounce, PC_Die, PC_Stop, PV_Direction, PV_Gravity, PV_KeyFrames, PV_Linear, PV_Random, PV_Sin, PV_Speed, PV_Step, PV_Wind
Zapper, 2013-10