problem with changing sprites

Discussion in 'Programming' started by Meve, Jan 11, 2019.

  1. Meve

    Meve Member

    Joined:
    Jan 21, 2018
    Posts:
    47
    Hello!
    So, basically I'm trying to make it so that if one of two objects is hit, they will respawn and flash until they can move, but when I run my code, there isn't any flashing.
    This is my code to set it to flashing:
    Code:
     if (freeze <= 0)
    {
        
    if key_up = 1
    {
          
         image_angle = 90;
        
    }
    if key_right = 1
    {
    
        image_angle = 0;
    }
    if key_left = 1
    {
    
        image_angle = 180;
    }
    if key_down = 1
    {
        
        image_angle = 270;
    }
            
    var move_sideways = key_right - key_left;
    hsp = move_sideways * h_speed;
    
    x = x + hsp;
    
    var move_up = key_down - key_up;
    vsp = move_up * v_speed;
    
    y = y + vsp;
    
    
    sprite_index = yellow_ship_flashing;
    }
    My code to set freeze in the bullet's step event:

    Code:
    /collision with ships
    
    if (place_meeting(x,y, ship_blue_obj)) or (place_meeting(x,y,Ship_yellow_obj))
    {
     if (place_meeting(x,y, ship_blue_obj))
        {
        with (Ship_yellow_obj)
        points_yellow++;
        }
        
        if (place_meeting(x,y, Ship_yellow_obj))
        {
        with (ship_blue_obj)
        points_blue++;
        }
        
        ship_blue_obj.x = 255;
        ship_blue_obj.y = 665;
        
        Ship_yellow_obj.x = 255;
        Ship_yellow_obj.y = 125;
        
        with(Ship_yellow_obj)
        {
        freeze = 50;   
        }
        
        rounds--;
    
        instance_destroy();
        
      
    }
    
    in the step event of ship_yellow_obj:
    Code:
    // cooldown time when killed
    
    freeze--;
    Hoped someone could help me :p
     
  2. Death

    Death Member

    Joined:
    Aug 8, 2018
    Posts:
    76
    Because you flash the ship ONLY if freeze is <=0, not while it is greater than 0?
     
  3. Meve

    Meve Member

    Joined:
    Jan 21, 2018
    Posts:
    47
    omg I'm stupid thanks
     

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