clearing particles[solved]

W

Wild_West

Guest
I'm having a problem with a particle setup.
I gave my character a simple shoot for a new game prototype I started. and rather than make a sprite for the "bullet" (more of an energy ball but whatever) I decided to make a particle effect.

so I did and it looks fine but when the object is destroyed, I need it to disappear so I can shoot another because the setup is you an only shoot 1 at a time. Meaning if 1 energy ball exists you can't make another until that one is gone. But it doesn't seem to be getting removed. The OBJECT will, but I can still see the particles from the last shot where that shot was destroyed.

I use part_type_clear in the object's destroy event, and it's destroyed when it leaves the room or hits a wall. I tried part_type_destroy, part_emitter_clear, but I can't get it to work. what am I doing wrong here?
 

FrostyCat

Redemption Seeker
The Manual entry for part_type_destroy() said:
Note that this function does not remove any particles currently visible in the room from the screen, for that you should be using part_particles_clear.
The Manual entry for part_system_destroy() said:
With this function you can destroy a given particles system and remove it from memory. This should always be called when the system is no longer needed, like at the end of a room, or in the destroy event of an instance, otherwise you could end up with particles appearing in later rooms and no way to remove them as well as a memory leak which will eventually crash your game.
 
W

Wild_West

Guest
Oh particles clear not type clear. There's so many of these I can never remember all of them.
Thanks
 
W

Wild_West

Guest
I actually had to use
part_type_destroy, part_emitter_clear AND part_particles_clear but it works
 

Carloskhard

Member
I actually had to use
part_type_destroy, part_emitter_clear AND part_particles_clear but it works
How did you solved this exactly?
I created the emitter like this:

//Particle System
part_sys_chispas = part_system_create();
part_system_depth(part_sys_chispas,-11);
//Particle
part_chispas = part_type_create();
//part_type_sprite(partPower,spr_humo,false,false,false);
part_type_shape(part_chispas,pt_shape_disk);
part_type_scale(part_chispas,0.5,0.5);
part_type_size(part_chispas,0.5,1.2,-.07,0);
part_type_alpha2(part_chispas,1,.5);
part_type_colour2(part_chispas,c_yellow,c_red);
part_type_life(part_chispas,room_speed/1.8,room_speed/2);
part_type_blend(part_chispas,false);
//Particle Emitter
part_emit_chispas = part_emitter_create(part_sys_chispas);
*chispas means sparkle in spanish..yeo I write half and half spanish english in my code jaja

part_emitter_region(part_sys_chispas,part_emit_chispas,x-70,x+70,y-70,y+70,ps_shape_ellipse,ps_distr_gaussian);
if (hp < 4) particulas = 3;
else if (hp < 7) particulas = 2;
else if (hp < 10) particulas = 1;
else particulas = 0;
part_emitter_stream(part_sys_chispas,part_emit_chispas,part_chispas,particulas);
*particulas means partciles and in this code I check for the hp of the object to create more or less particles

But then I destroy event of that object I do this:

Code:
part_particles_clear(part_emit_chispas)
part_type_destroy(part_chispas)
part_emitter_clear(part_sys_chispas,part_emit_chispas)
If I just use:
Code:
part_particles_clear(part_emit_chispas)
part_emitter_clear(part_sys_chispas,part_emit_chispas)
doesn`t work and particles keep being generated.
And if I add the line "part_type_destroy(part_chispas)" the game crashes automatically when the line executate...

What is wrong? Thanks
 
Last edited:
W

Wild_West

Guest
How did you solved this exactly?
I created the emitter like this:

//Particle System
part_sys_chispas = part_system_create();
part_system_depth(part_sys_chispas,-11);
//Particle
part_chispas = part_type_create();
//part_type_sprite(partPower,spr_humo,false,false,false);
part_type_shape(part_chispas,pt_shape_disk);
part_type_scale(part_chispas,0.5,0.5);
part_type_size(part_chispas,0.5,1.2,-.07,0);
part_type_alpha2(part_chispas,1,.5);
part_type_colour2(part_chispas,c_yellow,c_red);
part_type_life(part_chispas,room_speed/1.8,room_speed/2);
part_type_blend(part_chispas,false);
//Particle Emitter
part_emit_chispas = part_emitter_create(part_sys_chispas);
*chispas means sparkle in spanish..yeo I write half and half spanish english in my code jaja

part_emitter_region(part_sys_chispas,part_emit_chispas,x-70,x+70,y-70,y+70,ps_shape_ellipse,ps_distr_gaussian);
if (hp < 4) particulas = 3;
else if (hp < 7) particulas = 2;
else if (hp < 10) particulas = 1;
else particulas = 0;
part_emitter_stream(part_sys_chispas,part_emit_chispas,part_chispas,particulas);
*particulas means partciles and in this code I check for the hp of the object to create more or less particles

But then I destroy event of that object I do this:

Code:
part_particles_clear(part_emit_chispas)
part_type_destroy(part_chispas)
part_emitter_clear(part_sys_chispas,part_emit_chispas)
If I just use:
Code:
part_particles_clear(part_emit_chispas)
part_emitter_clear(part_sys_chispas,part_emit_chispas)
doesn`t work and particles keep being generated.
And if I add the line "part_type_destroy(part_chispas)" the game crashes automatically when the line executate...

What is wrong? Thanks

Sorry for the late reply I don't check in here often. but I think when you use Part_particles_clear() you need to put in the particle system name not the emitter name
 

Carloskhard

Member
Sorry for the late reply I don't check in here often. but I think when you use Part_particles_clear() you need to put in the particle system name not the emitter name
You're right! However this code just erase the particles in screen but doesn't stop the stream, so particles keep being created after. In fact I don't think I'll use this line anyway since I don't want the already existing particles to dissappear suddenly but rather stop the streaming.

I can't understand why using "part_emitter_clear(part_sys_chispas,part_emit_chispas)" doesn't delete the emmiter :confused:
 
Last edited:
W

Wild_West

Guest
You're right! However this code just erase the particles in screen but doesn't stop the stream, so particles keep being created after. In fact I don't think I'll use this line anyway since I don't want the already existing particles to dissappear suddenly but rather stop the streaming.

I can't understand why using "part_emitter_clear(part_sys_chispas,part_emit_chispas)" doesn't delete the emmiter :confused:
well isn't there a part_emitter_destroy() function too?
 
Top