RefresherTowel
Member
GM Version: 2
Target Platform: Windows/Mac
Download: N/A
Links: https://refreshertowel.games/2020/08/04/tutorial-particle-effects-in-gml/
Summary:
Learn how to create your own unique and interesting particle effects like this:
Tutorial:
Tutorial can be found here: https://refreshertowel.games/2020/08/04/tutorial-particle-effects-in-gml/
Here's Part 1 of 4:
Download the .yyz project file and import it into GMS2 (File > Import Project > Select the sweet-particle-effects.yyz file wherever you downloaded it to) to have easy access to the code and mess around with the particles yourself. Please note, I have altered some of the particle settings a little bit for the project file, to make them display better. Here’s a preview of it:
Part 1: Making your first particle
First, let’s see what the wormhole particles look like (after being embiggened somewhat):
So, first things first, what do we need to start creating particles? We’ll need a particle system. Let’s get that going. Open up the Create Event of the object you want to spawn the particles in and type in:
Now, what we’ve done there is create a particle system called
Now we’ll need to setup one particle emitter (the actual wormhole particles can be created without an emitter, but the line connecting the two needs one).
That’s nice and simple, just creating a particle emitter called
So far, we haven’t actually created any particles. That’s about to change. Let’s create our first particle:
Now let’s mosey on over to the Step Event and add in a quick bit of code to create those particles in-game:
And then pop open the Draw Event and enter this code to get the particles to draw:
As a side note, the reason that I manually draw the particles is because you can then position exactly where the particles will be drawn, layer-wise. For example, I could do this:
And the particles will be drawn above sprite1 and below sprite2. If you didn’t want to do this, you can just remove the line
Run the game and tada! We now have particle effects. But they look pretty damn bad:
We have to give the particle some properties to make it look better...
Continue on with Part 2
Target Platform: Windows/Mac
Download: N/A
Links: https://refreshertowel.games/2020/08/04/tutorial-particle-effects-in-gml/
Summary:
Learn how to create your own unique and interesting particle effects like this:
Tutorial:
Tutorial can be found here: https://refreshertowel.games/2020/08/04/tutorial-particle-effects-in-gml/
Here's Part 1 of 4:
Download the .yyz project file and import it into GMS2 (File > Import Project > Select the sweet-particle-effects.yyz file wherever you downloaded it to) to have easy access to the code and mess around with the particles yourself. Please note, I have altered some of the particle settings a little bit for the project file, to make them display better. Here’s a preview of it:
Part 1: Making your first particle
First, let’s see what the wormhole particles look like (after being embiggened somewhat):
So, first things first, what do we need to start creating particles? We’ll need a particle system. Let’s get that going. Open up the Create Event of the object you want to spawn the particles in and type in:
Code:
// ** Particle System: wormhole_ps_upper **
wormhole_ps_upper = part_system_create();
part_system_layer(wormhole_ps_upper ,layer);
part_system_automatic_draw(wormhole_ps_upper ,false);
wormhole_ps_upper
(I often create two separate particle systems, one to be drawn below the instance and one to be drawn above, which is why there’s the _upper postfix on there, but we don’t need two for this effect). Then we make sure the particle system is on the correct layer (setting it to layer simply makes sure the particle system is on the same layer as the instance creating it) and finally, we cancel automatic drawing of the particle system. This is because it gives you a little more control over exactly which depth the particles will appear. A particle system is necessary in order to create particles.Now we’ll need to setup one particle emitter (the actual wormhole particles can be created without an emitter, but the line connecting the two needs one).
Code:
// ** Particle Emitter : wormhole_connect_emit **
wormhole_connect_emit = part_emitter_create(wormhole_ps_upper);
wormhole_connect_emit
and linking it to wormhole_ps_upper
.So far, we haven’t actually created any particles. That’s about to change. Let’s create our first particle:
Code:
// ** Particle : wormhole_part **
wormhole_part = part_type_create();
Code:
part_particles_create(wormhole_ps_upper, mouse_x, mouse_y, wormhole_part, 10);
Code:
part_system_drawit(wormhole_ps_upper);
Code:
draw_sprite(sprite1,0,x,y);
part_system_drawit(wormhole_ps_upper);
draw_sprite(sprite2,0,x,y);
part_system_automatic_draw(wormhole_ps_upper ,false);
from the Create Event and the particles will automatically draw themselves.Run the game and tada! We now have particle effects. But they look pretty damn bad:
We have to give the particle some properties to make it look better...
Continue on with Part 2
Last edited: