GMS 2 [SOLVED] Sprite dissapearing after four seconds of input

Discussion in 'Programming' started by Nuclear Detergent, Sep 12, 2019.

Tags:
  1. Nuclear Detergent

    Nuclear Detergent Member

    Joined:
    Aug 21, 2019
    Posts:
    16
    So I'm fairly new to GMS2 programming. I have a strange bug. Here's the code:

    Code:
    Step event
    
    if lockKeys = 0 {
    //Do a million things based on player input
    }
    
    if key_up {
        sprite_index = sPlayerH;
        lockKeys = 1;
        firingdelay = 0;
    }
    else {
        lockKeys = 0;
    }
    I want the player input to be locked, when the arrowkey up is pushed. So I have a variable that controls whether or not input can be made, if the arrowkey up is pressed or not. It works perfectly fine, except it dosen't. If no other input is given, when the game starts, and the arrowkey up is held for more than 4 seconds, and then released, the player object dissapears. If other inputs are given before holding the up key, it takes roughly 8 seconds for the player object to dissapear.

    This is fairly odd. I have different speeds on my sprites - could this be the cause of the problem, or does anyone have any other idea?
     
  2. spoonsinbunnies

    spoonsinbunnies Member

    Joined:
    Aug 24, 2018
    Posts:
    111
    we would deffinitly need to see more of your code to help, to verify if the player object is actually being deleted, or is simply flying away from something unforeseeable I would suggest having a draw even to draw a circle at a set coordinate, if the player disappears, but the circle stays, it means the player is flying away and not being deleted, or having its alpha or visible tampered.
     
    Nuclear Detergent likes this.
  3. Nuclear Detergent

    Nuclear Detergent Member

    Joined:
    Aug 21, 2019
    Posts:
    16
    Thanks, the drawing/message tip is good for bug testing - it really helped me test things.

    It wasn't a flying problem, nor an object being deleted. It seemed to be something being reactivated assynchonous when releasing the arrowkey up. It's solved now :)
     

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