Touch screen, pause game, how do you differentiate?

DrGlickertDrGlickert Member Posts: 1,135
edited November -1 in Working with GS (Mac)
So i have a game where the player touches the screen to fire a shot. I also have a pause game button that the player touches to pause the game. How do I get it so that the player touches the pause button but WON'T fire a shot as well?

It wouldn't be a big deal but the shot's are calculated and points are awarded based on shots, etc etc. So i kind of have to have the shot NOT FIRE when the pause button is pressed...

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    you can have a boolean attribute called pause and have it set to false. On all your rules to shoot and stuff have when touch is pressed and pause is false. Then in the pause button have when touch is pressed and touch is inside change pause to true and pause. Then when you unpause change pause back to false.

    That should disable everything else in the game when you press the pause button and not trigger anything else
  • DrGlickertDrGlickert Member Posts: 1,135
    That doesn't work JP. It still fires a shot. Is there a way to make it on top of the layer or something?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    you can try having a rule for your shot if pause is false and touch is pressed after 0.1 seconds fire shot.

    Then in the pause have when touch is pressed and inside change pause to true

    that should trigger the pause first and disable the fire before it has a chance to fire
  • Rob2Rob2 Member Posts: 2,402
    Just use touch is outside to swing a game boolean from your pause button and check for that state as well in your fire touch rule.
  • xarmianxarmian Member Posts: 124
    I've used the 0.1 timer with success, but I found an even better option for this scenario. Since the pause button is usually in a corner (let's say top-left corner) make your "fire" rule something like:

    RULE #1
    - mouse button down
    (NESTED) Rule #2 - When ANY are true:
    - Device.Touch1.Position.X is > 30
    - Device.Touch1.Position.Y is < 290
    DO FIRE BEHAVIOR

    This example would be for a landscape screen and leaves the 30x30 section of pixels at the top left corner for pressing the pause button. Any press outside that corner would trigger the fire behavior. You'll need to modify this depending on the size of your pause button, which you can just calculate.

    Dave
Sign In or Register to comment.