• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

part_system_automatic_update

D

Darren

Guest
I'm using part_system_automatic_update in my pause menu to pause the particles I use for explosions but it doesn't seem to be working. occasionally it will continue after I unpause but it seems 50/50, another issue is no matter what, I still see the explosion when I pause.

Can anybody tell me what I'm doing wrong here?

Here's my code

if pause = 1
{
if instance_exists(o_particles)
{
if part_emitter_exists(o_particles.system, o_particles.explosion_centre_part)
{
part_system_automatic_update(o_particles.explosion_centre_part, false);
}
if part_emitter_exists(o_particles.system, o_particles.explosion_particle_part)
{
part_system_automatic_update(o_particles.explosion_particle_part, false);
}
if part_emitter_exists(o_particles.system, o_particles.smoke_particle_part)
{
part_system_automatic_update(o_particles.smoke_particle_part, false);
}
}

I then have the same for if pause = 0 true on all of them, although this seems to make no difference whether I include it or not.
 

Phil Strahl

Member
How about this: When you create the particle system, you set it part_system_automatic_update() to false. And in its step event code, you update it manually by invoking part_system_update(), unless the game is paused.
 
D

Darren

Guest
Thanks! That's a really good idea, and something I'll be trying if I can't fix this, but I'd quite like to be able to do everything from the pause menu. Or at the very least, I want somebody to tell me WHY this isn't working in this way.

Could it be that by deactivating the instance that calls the particles it's then not able to find it and stop it updating? That was my thought, but then when I put my particle pause code before deactivating the instances it made no difference.

I'm finding it really strange that this works probably a quarter of the time and not the rest. But it ALWAYS shows the explosion in the pause menu, even if it does manage to reactivate it when I unpause.
 
D

Darren

Guest
Worth noting I've added part_system_automatic_draw too, hasn't made a difference.

if instance_exists(o_particles)
{
if part_emitter_exists(o_particles.system, o_particles.explosion_centre_part)
{
part_system_automatic_update(o_particles.explosion_centre_part, false)
part_system_automatic_draw(o_particles.explosion_centre_part, false)
}
if part_emitter_exists(o_particles.system, o_particles.explosion_particle_part)
{
part_system_automatic_update(o_particles.explosion_particle_part, false)
part_system_automatic_draw(o_particles.explosion_particle_part, false)
}
if part_emitter_exists(o_particles.system, o_particles.smoke_particle_part)
{
part_system_automatic_update(o_particles.smoke_particle_part, false)
part_system_automatic_draw(o_particles.smoke_particle_part, false)
}
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Instead of having all this "ifs" just use "with". That way if it doesn't exist then it doesn't matter, as the "with" will simply skip the code... So:

Code:
if pause
{
with (o_particles)
    {
    part_system_automatic_update(system, false);
    }
}
else
{
with (o_particles)
    {
    part_system_automatic_update(system, true);
    }
}
Also, your code looks pretty confusing and I'm wondering just how you are creating the system, emitters and particles... To be honest, you should probably create a GLOBAL system and particles, then local emitters (or omit the emitters entirely if you can because they are a pain to use and part_particles_create() can often do the same job more efficiently). Have you read my article on using particles? If not maybe give it a look over as I suspect that you are doing something wrong somewhere (sorry!)... http://www.yoyogames.com/blog/50

PS: Just because you switch off automatic updates for the system does not mean that particles won't get spawned... they might be, only once spawned they won't be updated, so you probably want to wrap any emitters in an "if pause" check....

PPS: Also, learn to format your code with proper tabs for different levels of if/then/else!!!!! Makes it MUCH easier to follow and understand what exactly is going on. ;)
 
D

Darren

Guest
Appreciate you taking the time to reply, thanks!

Yeah sorry, bad habit but I tend to write my code messily when I'm rushing to get it done and then once it works clean it up and make it more efficient.

I create it like this

///Initialize the particles
system = part_system_create();

// Create 3 particles
explosion_centre_part = create_part_type_sprite(s_explosion_centre, true, 30, 30, .2, .3, -.001);
explosion_particle_part = create_part_type_sprite(s_explosion_particle, true, 15, 20, .1, 0.4, -.01);
smoke_particle_part = create_part_type_sprite(s_smoke_particle, true, 15, 15, .1, .4, -.01);

and then call it with this

///Create the explosion particles
part_particles_create(o_particles.system, x-8+random(16), y-8+random(16), o_particles.explosion_particle_part, 1);
part_particles_create(o_particles.system, x-8+random(16), y-8+random(16), o_particles.smoke_particle_part, 1);

I've now wrapped the emitter code so it will only create if the game is not paused but it's still doing it. It's so strange, it works 1/4th of the time. I don't get why sometimes it works, sometimes it doesn't.
 
Top