particle_get_info

This function returns a struct with information about a Particle System Asset created using The Particle System Editor.

The returned struct is a Particle System Info Struct, which contains an Array of Particle Emitter Info Structs. Each of these emitter structs stores info on the particle type that the emitter uses in its parttype variable, which contains a Particle Type Info Struct.

WARNING If no valid Particle System Asset is passed to the function, GameMaker will throw an error.

In a simplified way, the contents of the struct returned by this function look something like the following:

part_sys_info_struct =
{
    emitters:
    [
        {
            parttype:
            {
                // Particle type properties...
            }
            // All other particle emitter properties...
        }
        // More emitters...
    ]
    // All other particle system properties...
};

The tables below list all variables that are available in each of these three structs.

Particle System InfoParticle System Info

Particle System Info Struct
Variable NameData TypeDescription
nameStringThe name of the particle system asset.
xoriginRealThe X origin of the particle system.
yoriginRealThe Y origin of the particle system.
global_spaceBooleanWhether this particle system has global space particles enabled (see part_system_global_space).
oldtonewBooleanWhether old particles should be drawn behind new ones (true) or not (false).
emittersArray of Particle Emitter Info StructAn array of emitter info structs, ordered the same as in The Particle System Editor.

Particle Emitter InfoParticle Emitter Info

Particle Emitter Info Struct
Variable NameData TypeDescription
nameStringThe name of the emitter.
modeParticle Emitter Mode ConstantThe mode in which to emit particles. Either ps_mode_stream or ps_mode_burst.
enabledBooleanWhether the particle emitter is enabled.
numberRealThe number of particles to create every frame if mode is ps_mode_stream or to create only once if mode is ps_mode_burst. Density (percent coverage) when in relative mode.
relativeBooleanWhether the emitter is in relative mode, in which the number of particles created by the emitter is relative to the area of its region (see part_emitter_relative).
xminRealThe X coordinate of the left side of the emitter's region.
xmaxRealThe X coordinate of the right side of the emitter's region.
yminRealThe Y coordinate of the top of the emitter's region.
ymaxRealThe Y coordinate of the bottom of the emitter's region.
distributionParticle Emitter Distribution ConstantThe distribution style of the particles. One of the ps_distr_* constants.
shapeParticle Emitter Shape ConstantThe shape of the emitter's region. One of the ps_shape_* constants.
parttypeParticle Type Info StructThe particle type info struct containing information this emitter's particle type.
delay_minRealThe minimum delay between particle bursts in stream mode, expressed in delay_unit.
delay_maxRealThe maximum delay between particle bursts in stream mode, expressed in delay_unit.
delay_unitTime Source Unit Constant The unit in which delay_min and delay_max are expressed
interval_minRealThe minimum time between particle bursts in stream mode, expressed in interval_unit.
interval_maxReal The maximum time between particle bursts in stream mode, expressed in interval_unit.
interval_unitTime Source Unit ConstantThe unit in which interval_min and interval_max are expressed.

Particle Type InfoParticle Type Info

Particle Type Info Struct
Variable NameData TypeDescription
General
indParticle Type IDThe index of the particle type. This can be used e.g. with the function part_particles_create.
Shape / Sprite
spriteSprite AssetThe index of the sprite that the particle type uses or -1.
frameRealThe sprite subimage in case a sprite is used.
animateBooleanIf true then the sprite is animated, starting from the frame subimage.
stretchBooleanIf true then the animation is stretched over the particle's lifetime.
randomBooleanIf true then a random subimage is used instead of frame.
shapeParticle Shape ConstantThe particle shape. One of the pt_shape_* constants. Used only if sprite is -1.
Size
size_xminRealThe minimum size a particle of this type can have on the X axis when it is created (the size is determined randomly for each particle and can vary from size_xmin to size_xmax).
size_yminRealThe minimum size a particle of this type can have on the Y axis when it is created (the size is determined randomly for each particle and can vary from size_ymin to size_ymax).
size_xmaxRealThe maximum size a particle of this type can have on the X axis when it is created (the size is determined randomly for each particle and can vary from size_xmin to size_xmax).
size_ymaxRealThe maximum size a particle of this type can have on the Y axis when it is created (the size is determined randomly for each particle and can vary from size_ymin to size_ymax).
size_xincrRealThe value to increase/decrease the particle size on the X axis by each frame.
size_yincrRealThe value to increase/decrease the particle size on the Y axis by each frame.
size_xwiggleRealValue randomly added or subtracted from the particle's X size each frame.
size_ywiggleRealValue randomly added or subtracted from the particle's Y size each frame.
Scale
xscaleRealThe X scale of the particle image (sprite or shape).
yscaleRealThe Y scale of the particle image (sprite or shape).
Life
life_minRealThe minimum life of particles of this type (in number of frames).
life_maxRealThe maximum life of particles of this type (in number of frames).
Secondary Particles
death_typeParticle Type IDThe type of particle spawned on death or -1.
death_numberRealThe number of particles spawned on death.
step_typeParticle Type IDThe type of particle spawned each step or -1.
step_numberRealThe number of particles spawned each step.
Speed
speed_minRealThe minimum speed (in pixels per frame) of the particle when it's created (this starting speed is determined randomly for each particle and ranges from speed_min to speed_max).
speed_maxRealThe maximum speed (in pixels per frame) of the particle when it's created (this starting speed is determined randomly for each particle and ranges from speed_min to speed_max).
speed_incrRealThe value to increase/decrease the particle speed by each frame.
speed_wiggleRealA value randomly added or subtracted from the particle speed each frame.
Direction
dir_minRealThe minimum direction (in degrees) for a particle when it's created (this starting direction is determined randomly for each particle and ranges from dir_min to dir_max).
dir_maxRealThe maximum direction (in degrees) for a particle when it's created (this starting direction is determined randomly for each particle and ranges from dir_min to dir_max).
dir_incrRealThe value to increase/decrease the particle direction by each frame.
dir_wiggleRealA value randomly added or subtracted from the particle direction each frame.
Gravity
grav_amountRealThe amount of gravity applied to the particle each frame (in pixels per frame).
grav_dirRealThe gravity direction.
Orientation
ang_minRealThe minimum starting angle (in degrees) of the particle sprite when created (this starting angle is determined randomly for each particle and ranges from ang_min to ang_max).
ang_maxRealThe maximum starting angle (in degrees) of the particle sprite when created (this starting angle is determined randomly for each particle and ranges from ang_min to ang_max).
ang_incrRealThe value to increase/decrease the particle angle by each frame.
ang_wiggleRealA value randomly added or subtracted from the particle angle each frame.
ang_relativeBooleanIf true then the particle angle is relative to its direction.
Color & Alpha
color1ColourThe color of the particle when created.
color2ColourThe color of the particle when halfway through its lifespan.
color3ColourThe color of the particle at the end of its lifespan.
alpha1RealThe alpha of the particle when created.
alpha2RealThe alpha of the particle when halfway through its lifespan.
alpha3RealThe alpha of the particle at the end of its lifespan.
additiveBooleanIf true then the particle is drawn with additive blending (i.e. using the Blend Mode Constant bm_add).

 

Finally there is also a constant for the particle emitter mode: 

Particle Emitter Mode Constant
ConstantDescription
ps_mode_streamThe particle emitter streams the given number of particles continuously (see part_emitter_stream)
ps_mode_burstThe particle emitter emits a single burst of the given number of particles (see part_emitter_burst)

 

Syntax:

particle_get_info(partsys);

ArgumentTypeDescription
partsysParticle System AssetThe particle system asset to get the info from.

 

Returns:

Particle System Info Struct

 

Example 1: Particle Type Info

var _particle_info = particle_get_info(ps_Clouds);
var _asset_name = _particle_info.name;

var _arr_emitters = _particle_info.emitters;
if (array_length(_arr_emitters) > 0)
{
    var _type_info = _arr_emitters[0].parttype;
   
    if (_type_info.additive)
    {
        show_debug_message("The first emitter in {0} creates shiny particles!", _asset_name);
    }
}

The above code first gets information from an existing Particle System Asset ps_Clouds using particle_get_info and assigns the returned struct to a temporary variable _particle_info. It then looks up the emitters in the particle system through the Particle System Info Struct's emitters variable. If the particle system contains any emitters (i.e. the array's length is greater than 0), the first emitter's parttype variable is assigned to a temporary variable _type_info and checked for additive blending (bm_add). Finally a debug message is shown if additive blending is used for the particle type.

 

Example 2: Listing Emitter Names

var _particle_info = particle_get_info(ps_Environment);
var _asset_name = _particle_info.name;

var _emitter_names = array_map(_particle_info.emitters, function(_element, _index) { return _element.name; });
_emitter_names = string_join_ext(", ", _emitter_names);

show_debug_message("{0} contains the following particle emitters: {1}", _asset_name, _emitter_names);

The above code first calls particle_get_info to retrieve information about an existing Particle System Asset ps_Environment. The asset's name is stored in a temporary variable _asset_name. After that, an array of emitter names is generated from the Particle System Info Struct's emitters variable and converted to a string listing all names, separated by a comma, using string_join_ext. Finally a debug message displays the information in a readable form.