Spawning actor not responding to keypress if already down

ArcosArcos Member Posts: 1
edited July 2012 in Working with GS (Mac)
Hi,

I have actors randomly spawning off the screen, within the playfield though, that then automatically move vertically down the screen. I've set these actors to move left and right depending on which cursor key is pressed.

However it appears that if I'm holding a key down, let's say the left key, when the actor spawns and keep holding down the left key, the actor does not respond to the key being down and only moves down the screen and not left as well. If I let the key up and press again then it responds normally...

Not sure if I've encountered a bug or I'm missing something perhaps in spawning the actors?

Cheers

Best Answer

  • tenrdrmertenrdrmer Posts: 9,934
    Accepted Answer
    It does this because the event of the key being pressed down has already happened before the actor is spawned. It could be a bug but if it is its something that you have to deal with in GameSalad. Be sure and send in a bug report just incase.

    What I would do I create a game level attribute. Lets do integer type.

    And instead of your actors moving based on the key-press make them based on that game attribute. So…..

    When Game.Direction = 0
    --Change self.LienarVelocity.X to 0
    OtherWise
    --When Game.Direction = 1
    ----Move Left
    --Otherwise
    ----When Game.Direction = 2
    ------Move right


    Then Make you Keys Change game.direction to 0,1,or 2 based on whats pressed or not pressed

Answers

  • ArcosArcos Member Posts: 1
    Thanks tenrdrmer, your suggestion worked like a charm. I'll also log a bug report just in case.

    Cheers!
Sign In or Register to comment.