Windows looping object change

Discussion in 'Programming' started by krakk, Jun 11, 2019 at 9:19 PM.

  1. krakk

    krakk Member

    Joined:
    May 20, 2017
    Posts:
    9
    Hi, i'm struggling to make a looking object change,

    I'm managing to change one time, then it stops.

    I have this code in the 1ºst obj:


    Code:
    Create Event:
    
    set Alarm 0 to 45
    execute code:
    
    image_speed = 0.2
    
    Alarm Event for alarm 0:
    
    set Alarm 0 relative to 100
    change the instance into object lavafall2end, not performing events
    Begin Step Event:
    
    execute code:
    
    image_speed = 0.2;
    
    Other Event: Animation End:
    
    set the sprite to lavafall2 with subimage 0 and speed 0.2
    

    and then this on the 2nd obj:
    Code:
    Create Event:
    
    set Alarm 0 to 45
    execute code:
    
    image_speed = 0.2
    
    Alarm Event for alarm 0:
    
    set Alarm 0 relative to 100
    change the instance into object lavafall2begin, not performing events
    Other Event: Animation End:
    
    execute code:
    
    image_speed = 0;
    image_index = image_number - 1;
    
    

    what may be the problem?
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,033
    You need to enable performing events when changing the instance to another object. Your initial alarm sets are in the Create event, and disabling performing events would have skipped that.
     
    krakk likes this.
  3. krakk

    krakk Member

    Joined:
    May 20, 2017
    Posts:
    9
    In fact, they do the loop, but the 1st object starts with a sprite and then it changes to another in the animation end. When it loops, it goes to the second sprite and ignores the first one. like this:


    obj1:
    sprite_begin > animation end > sprite2 > timer > change to obj2

    obj2:
    sprite_end > timer > change to obj1

    So, it run ok the 1st time, then when it loops, the obj1 shows the sprite2 and don't start with the sprite_begin.
     

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