part_emitter_relative

This function sets relative mode for a particle emitter. With relative mode enabled, the number of particles created becomes relative to its area.

Usage Notes

 

Syntax:

part_emitter_relative(ps, ind, enable);

ArgumentTypeDescription
psParticle System InstanceThe index of the particle system the emitter belongs to
indParticle Emitter IDThe index of the particle emitter
enableBooleanWhether to enable or disable relative mode for the emitter

 

Returns:

N/A

 

Example:

 

Create Event

ps = part_system_create();
pe = part_emitter_create(ps);
part_emitter_region(ps, pe, 20, 120, 20, 120, ps_shape_rectangle, ps_distr_linear);
part_emitter_relative(ps, pe, true);
pt = part_type_create();
part_type_shape(pt, pt_shape_flare);

part_emitter_stream(ps, pe, pt, 2);

Cleanup Event

part_emitter_destroy(pe);
part_system_destroy(ps);
part_type_destroy(pt);

The above code creates a particle system ps and adds a single emitter pe to it. The emitter is set to emit particles in a rectangular region of 100x100 pixels, starting at (20, 20). It is then set to emit particles in relative mode. Next, a particle type is created and configured to draw a flare shape pt_shape_flare. Finally, the emitter is set to stream particles of the created type continuously. Since relative mode was enabled, the number of 2 means that the emitter will create the number of particles needed to cover 2% of the emitter area every step.