### Designing Games with GameMaker

### Attractors

Besides emitters a particle system can also contain attractors. An attractor attracts the particles (or pushes them away). A particle system can have multiple attractors. You are though recommended to use few of these because they will slow down the processing of the particles. An attractor has the following properties:indicate the position of the attractor.**x,y**indicates the attracting force of the attractor. How the force acts on the particles depends on the following parameters.**force**indicates the maximal distance at which the attractor has effect. Only particles closer that this distance to the attractor will be attracted.**dist**indicates the kind of attractor. The following values exist**kind**`ps_force_constant`indicates that the force is constant independent of the distance.`ps_force_linear`indicates a linearly growing force. At the maximal distance the force is 0 while at the position of the attractor it attains the given value.`ps_force_quadratic`indicates that the force grows quadratic.indicates whether the force is added to the speed and direction in each step (true) or only applied to the position of the particle (false). When additive the particle will accelerate towards the attractor while with a non-additive force it will move there with constant speed.**additive**

The following functions exist to define attractors. Note that each of them gets the index of the particle system to which it belongs as a first argument.

Creates a new attractor in the given particle system. It returns the index of the attractor. This index must be used in all calls below to set the properties of the attractor.part_attractor_create(ps)

Destroys attractor ind in the particle system. Call this if you don't need it anymore to save space.part_attractor_destroy(ps,ind)

Destroys all attractors in the particle system that have been created.part_attractor_destroy_all(ps)

Returns whether the indicated attractor exists in the particle system.part_attractor_exists(ps,ind)

Clears the attractor ind to its default settings.part_attractor_clear(ps,ind)

Sets the position of attractor ind to (x,y).part_attractor_position(ps,ind,x,y)

Sets the force parameters of attractor ind.part_attractor_force(ps,ind,force,dist,kind,aditive)

« Emitters | Destroyers »

### Alternative versions

You can also read this manual on one single long page (± 1.5 mb)

Also available in:

Download helpfile

Also available in:

Download helpfile