创建粒子发射器


描述

为了能够看到你的粒子,你需要先创建一个粒子系统,然后定义了一些粒子类型最后使用此动作创建了一个粒子发射器。要创建发射器,可以调用此操作并将发射器分配给先前创建的粒子系统(请参阅粒子系统)然后给出一个目标变量来存储它的唯一ID值,以便在进一步的操作中使用。You can choose to flag this variable as being a temporary local variable, but that will mean that it is discarded at the end of the action script or event, meaning that the emitter will still exist but leave you without any means to access it, so care must be taken when using this (in general emitters will never need to be stored in a temporary local variable, but for certain things, like drawing particles to a surface, it may be required).

IMPORTANT! If your particle system is persistent then you must either destroy all emitters at the end of each room using Destroy Particle Emitter and re-create them again in the next room as required, or store their ID values in global variables so that they can be accessed anytime in any room, or have them created by a persistent object, so that the object will persist and be able to access them through instance variables. Also note that if you call the Restart Game action you should destroy the particle system beforehand so that the system and the emitters assigned are removed from memory before starting again. Failure to properly remove emitters from system memory as outlined above will lead to a memory leak. This happens when a resource is added to memory and then "de-referenced", meaning that GameMaker Studio 2 has no way to interact with that resource any more. This leads to the memory being clogged by inaccessible resources which in turn can cause issues with your game.


动作语法:

Create Particle Emitter Syntax


参数:

参数 描述
系统 The ID value for the global emitter to create
目标 The target variable to hold the emitter ID


例如:

Create Particle Emitter Example
The above action block code will create a particle emitter, set it's region, and then set it to emit a stream of particles.