GMS 2 [SOLVED] Particles don't resume after pausing

Discussion in 'Programming' started by Freppe, Jun 13, 2018 at 4:32 PM.

  1. Freppe

    Freppe Member

    Joined:
    May 26, 2018
    Posts:
    7
    After setting up at trail for my spacecraft I wanted the particles to pause along with the other instances. I used part_system_automatic_update() for this. I set it up in my pause event so that whenever the instances were deactivated the function turned of the updates. When the instances were activated again the function were to set updates to true again but for some reason it didn't. I tried not disabling the particles object and all but nothing seems to work. The particles won't turn on again.

    Here's the pause objects step event:
    Code:
    if (!pause)
    {
        pause = 1;
        with (oParticles) part_system_automatic_update(partTrail_sys,false);
        instance_deactivate_layer("Instances");
        instance_create_depth(0,0,-100,oMenu);
        with (oMenu) menu[0] = "Resume";
    }
    else
    {
        pause = 0;
        instance_activate_layer("Instances");
        with (oParticles) part_system_automatic_update(partTrail_sys,true);
        instance_destroy(oMenu);
    }
    
    Here is the particle objects create event:
    Code:
    //Particle System
    partTrail_sys = part_system_create();
    part_system_depth(partTrail_sys,200);
    
    
    //Particle
    partTrail = part_type_create();
    part_type_sprite(partTrail,sTrail,true,true,false);
    part_type_scale(partTrail,1,1);
    part_type_size(partTrail,0.5,0.5,-0.005,0);
    part_type_alpha2(partTrail,1,0.5);
    part_type_speed(partTrail,0,0,0,0);
    part_type_gravity(partTrail,0,90);
    part_type_life(partTrail,room_speed*5,room_speed*5);
    part_type_blend(partTrail,false);
    
    
    //Particle Emitter
    partTrailLeft_emit = part_emitter_create(partTrail_sys);
    partTrailRight_emit = part_emitter_create(partTrail_sys);
    leftX = oPlayer.x + lengthdir_x(30,oPlayer.image_angle + 155);
    leftY = oPlayer.y + lengthdir_y(30,oPlayer.image_angle + 155);
    rightX = oPlayer.x + lengthdir_x(30,oPlayer.image_angle + 205);
    rightY = oPlayer.y + lengthdir_y(30,oPlayer.image_angle + 205);
    part_emitter_region(partTrail_sys,partTrailLeft_emit,leftX,leftX,leftY,leftY,ps_shape_ellipse,ps_distr_gaussian);
    part_emitter_region(partTrail_sys,partTrailRight_emit,rightX,rightX,rightY,rightY,ps_shape_ellipse,ps_distr_gaussian);
    part_emitter_stream(partTrail_sys,partTrailLeft_emit,partTrail,4);
    part_emitter_stream(partTrail_sys,partTrailRight_emit,partTrail,4);
    
    And the particle objects step event:
    Code:
    part_emitter_region(partTrail_sys,partTrailLeft_emit,leftX,leftX,leftY,leftY,ps_shape_ellipse,ps_distr_gaussian);
    part_emitter_region(partTrail_sys,partTrailRight_emit,rightX,rightX,rightY,rightY,ps_shape_ellipse,ps_distr_gaussian);
    
    What it looks like after resuming the game:
    [​IMG]
     

    Attached Files:

  2. Simon Gust

    Simon Gust Member

    Joined:
    Nov 15, 2016
    Posts:
    2,396
    Thinking of 2 potential problems.
    1. If your pause object is on the "Instances" layer, it will deactivate itself and not be able to activate again
    2. Activation / Deactivation takes a step to realize. So using a with() loop may not work yet in that step.
    You could make an alarm an put the code there or have a controller object that doesn't depend on any object other than itself.
    Meaning you should put pausing and particles in the same object.
     
  3. Freppe

    Freppe Member

    Joined:
    May 26, 2018
    Posts:
    7
    Thank you so much!
    Your answer didn't fix my problem directly but it made me come up with a solution. I merged the particle system with the player instead and turned off part_system_automatic_update() in the create event so that I could run part_system_update() every frame in the step event. This means the particle system won't update whenever the player is deactivated.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice