#GML PARTICLE DESIGNER CODE#
There are a lot of details that can be used to define a particle effect, so to show them we'll post an overview of the most important settings and then a snippet of code and DnD™ that uses all of them: We now have a system and a particle to put in it, but we're not ready yet to create our outstanding effects! We still have to define the general properties of our particle, ie: how it looks - its speed, its rotation, its alpha etc. However, to keep things simple for this tutorial, we'll not be using persistence. A persistent particle system is one that will "persist" across rooms without the need to destroy and re-create it for each room. Also note that we set the "persistent" flag (both in code and in DnD™) to false. This enables additive blending for the particle, which we'll discuss a bit further on in the article. Note that using DnD™ we also tick the blend option.
The GML would look like this: global.P_System = part_system_create_layer("Instance_Layer", false) As this is going to be a global system that any object can use we will do it in a controller object or an initialisation script run at the start of the game. To start with we need to define the particle system and give it a name so that we can use it. In this blog we will make a global particle system that can be used by any instance in the game at any time. We do this because a particle system, once created, stays in memory and is ready to be used at any time, so if you create it more than once it can quickly up the memory usage and cause serious lag, and even has the potential of crashing the game. First is that most of a particle systems code is only ever called once in the game, usually in some type of controller object in the first room or level - this is not always the case, but for the sake of simplicity, we'll be using this scenario for this tech blog as it's the most common way to use particles. Well, before setting up a system it's important to know a few things. We use code or actions to define the visual aspect of our particle, and then we place it in the "container" so that we can take it out and use it whenever and wherever we need it later. Think of a particle system like a container that we will use to hold our particles ready for use. They are very useful for creating beautiful and flashy effects (or subtle and discreet ones!) in a game without the CPU overhead that using instances has. These properties cannot be manipulated directly for individual particles, but are changed through the code or actions that are used to define the system that it belongs to. Basically, a particle is a graphic resource that has certain properties which are defined by a particle system. We'll be covering both GML (the GameMaker Language) and Drag and Drop™, so if you've never used particles before, we hope that this guide can get you started as they are very useful and quite fun to make!īefore going any further, we should probably explain what a particle actually is.
In todays tech blog we're going to take a look at creating particles.