Emitter Ranges - Grisgram/gml-raptor GitHub Wiki

Emitter ranges

Each emitter has a range. This is a geometric shape (a rectlange, a diamond, an ellipse or a line) with a specific width and height. When you stream or burst particles, the emitter distributes them randomly, based on an algorithm, inside its range. You define the shape, dimension and algorithm used for a range in the Particle Editor.
However, at runtime there will be the need to set the range at specific coordinates (imagine a flame-effect for a torch, where you emit fire particles to make the flame come to life,... you will want to move the range near the center of the torch, where the flame starts).

You control the range of an emitter with these functions:

emitter_set_range

/// @function		emitter_set_range(name_or_emitter, xmin, xmax, ymin, ymax, shape, distribution)
/// @description	Set the range of an emitter
/// @param {string} name_or_emitter	The emitter name you set in the Particle Editor
/// @param {real} xmin		The left edge of the range
/// @param {real} xmax		The right edge of the range
/// @param {real} ymin		The top edge of the range
/// @param {real} ymax		The bottom edge of the range
/// @param {constant} shape	The shape of the range. Must be one of
///				ps_shape_diamond, ps_shape_ellipse, ps_shape_line, ps_shape_rectangle
/// @param {constant} distribution	The distribution algorithm. Must be one of
///					ps_distr_gaussian, ps_distr_invgaussian, ps_distr_linear
static emitter_set_range = function(name_or_emitter, xmin, xmax, ymin, ymax, shape, distribution) {

emitter_move_range_by

/// @function		emitter_move_range_by(name_or_emitter, xdelta, ydelta)
/// @description	Move the range of the emitter by the specified delta, keeping its size, 
///			shape and distribution.
///			Use this, if an emitter shall follow another object on screen (like the mouse cursor)
/// @param {string} name_or_emitter	The emitter name you set in the Particle Editor
/// @param {real} xdelta		The horizontal distance to move
/// @param {real} ydelta		The vertical distance to move
static emitter_move_range_by = function(name_or_emitter, xdelta, ydelta) {

emitter_move_range_to

/// @function		emitter_move_range_to(name_or_emitter, newx, newy)
/// @description	Move the range of the emitter a new position, keeping its shape and distribution.
///			Use this, if an emitter shall follow another object on screen (like the mouse cursor)
/// @param {string} name_or_emitter	The emitter name you set in the Particle Editor
/// @param {real} newx		The new x-position of the range
/// @param {real} newy		The new y-position of the range
static emitter_move_range_to = function(name_or_emitter, newx, newy) {

emitter_scale_to

This one is a very handy convenience function. It scales the range of an emitter to match the dimensions (and position) of an object instance in the room.

/// @function		emitter_scale_to(name_or_emitter, instance)
/// @description	scales the emitter range to a specified object instance (size and position)
/// @param {string} name_or_emitter	The emitter name you set in the Particle Editor
/// @param {instance} instance	The object instance to scale the emitter's range to
static emitter_scale_to = function(name_or_emitter, instance) {

Query emitter ranges

These functions retrieve the min/max coordinates for an Emitter range. You receive a Coord2 instance holding the values (see Coordinate Helpers).

emitter_get_range_min

/// @function		emitter_get_range_min(name_or_emitter)
/// @description	Gets the min coordinates of an emitter as Coord2 or Coord2(-1,-1) if not found
static emitter_get_range_min = function(name_or_emitter) {

emitter_get_range_max

/// @function		emitter_get_range_max(name_or_emitter)
/// @description	Gets the max coordinates of an emitter as Coord2 or Coord2(-1,-1) if not found
static emitter_get_range_max = function(name_or_emitter) {

Continue reading in Multiple Emitters.

⚠️ **GitHub.com Fallback** ⚠️