Main > Features > Particle Effects

Tiny2D supports sophisticated particle effects consisting of
multiple emitters - all described via simple XML files.

Effect contains emitters. Emitters spawn particles.
Particles get updated every frame.

Particles can either be simulated in emitter's local space
or in the world space.

Each emitter has numerous properties described via
either: constant, range, key-frames (track) or key-framed ranges.
These properties include spawn frequency, color of the particles,
size of the particles and much more.

Blending of the particles is done as per material's technique
(see materials). This can be overridden by specifying custom
material and technique (see below).

Below is an example XML file describing particle effect that
spawns stars:

<?xml version="1.0" encoding="utf-8"?>
			<spawnArea type="point"/>
			<emitterLifeTotal value="5"/>
			<emitterCyclesTotal value="1"/>
			<initialSpawnCount min="3" max="10"/>
			<spawnCountOverEmitterLife value="100"/>
			<lifeTotalOverEmitterLife min="0.8" max="2.5"/>
			<sizeOverParticleLife value="15"/>
			  <key time="0" value="1"/>
			  <key time="1" value="1.5"/>
			  <key time="0" min="-230 -230" max="230 230"/>
			  <key time="0.6" min="-130 -130" max="130 130"/>
			  <key time="0.7" min="-100 -100" max="100 100"/>
			  <key time="0" value="1 0 0 0"/>
			  <key time="0.1" value="1 1 0 0.9"/>
			  <key time="0.33" value="0 1 1 0.9"/>
			  <key time="0.66" value="1 1 1 0.9"/>
			  <key time="0.9" value="1 0 1 0.9"/>
			  <key time="1" value="1 1 1 0"/>
			<initialRotationOverEmitterLife min="0" max="6.28"/>
			<rotationSpeedOverParticleLife min="10" max="20"/>

Sample code:

// Declaration

Effect effect;

// Initialization (from my_effect.effect.xml)


// Updating

effect.SetPosition(x, y);

// Drawing


List of all supported emitter properties:
(all except for colorMap are optional)

colorMapstring(no default)color texture map
materialstringcommon/defaultmaterial to use
techniquestringtex_vcoltechnique to use
maxParticlesint16maximum number of particles
localSimulationbooleantrueif set to true, particle simulation is done in emitter's local space
spawnAreastringpointparticle spawn area relative to emitter; possible values:
  • point
  • rectangle (requires: width, height)
  • circle (requires: radius)
initialSpawnCountfloat range0number of particles to spawn at start
initialVelocityvector-2 rangemin:(-1,-1) max:(1,1)initial particles velocity
initialRotationfloat rangemin:-Pi max:Piinitial particles rotation
cyclesTotalOverEmitterLiferanged float track1.0total number of particle life cycles over emitter life
lifeTotalOverEmitterLiferanged float track2.0total particle life cycle length over emitter life
velocityOverParticleLiferanged vector-2 track(none)particle velocity vector over particle life
accelerationOverParticleLiferanged vector-2 track(0,-10)particle acceleration vector over particle life
colorOverParticleLiferanged color track(1,1,1,1)particle color as RGBA over particle life
sizeOverParticleLiferanged vector-2 track(50,50)size (width and height) of the particles over particle life
rotationSpeedOverParticleLiferanged float track0.5 * Piparticle rotation speed over particle life
spawnCountOverEmitterLiferanged float track10.0particle spawn count over emitter life
colorOverEmitterLiferanged color track(1,1,1,1)particle color scale over emitter life
sizeScaleOverEmitterLiferanged float track1.0particle size scale over emitter life
rotationScaleOverEmitterLiferanged float track1.0particle rotation speed scale over emitter life
emitterCyclesTotalfloat range1.0number of emitter life cycles
emitterLifeTotalfloat range10.0length of emitter life cycle

Note on meaning of some of the value types:
  • range specifies minimum and maximum value; random number generator is used to pick values during simulation
  • ranges can be specified by min and max or just value (min equals max)
  • vector-2 is specified by two float values separated by an empty space
  • color is specified by four float values separated by an empty space
  • ranged tracks can be specified either via separate keys (each specified in the same way as a range) or in the same way as a single range (this will be turned automatically into single key track)
  • all keys in a track should have 'time' within 0..1 range

Contact: contact at pixelelephant dot com
(C) 2013 Pixel Elephant - All Rights Reserved