GameSalad

One button 2 jobs

quinn221quinn221 Posts: 280Member, PRO

Hey Guys,

I think i have a fairly simple problem ( Well at least I thought so, but I am unable get it to work)

I am working on my runner game project. It is set up so right away the actor starts to run to the right I Also want the actor to switch directions when pressing a button. But with the same button, if the player presses it again he will switch back to going right....and if the player presses it again it will go back to the left.....

Here is how I have my button set up

Left
Actor receives event touch is pressed:
Change attribute game.switchdirections to 1

Right
Actor receives event touch is pressed:
Change attribute game.switchdirections to 0

how do I reset the button back to 0 once pressed the second time?

What is the best way to make this work....I understand why it is not working, but I can't figure out how to work around it.

Comments

  • quinn221quinn221 Posts: 280Member, PRO

    Actually guys, It is working now.

  • SocksSocks London, UK.Posts: 12,711Member
    edited March 20

    If 'switchdirections' is an Interger/Real:

    When touch is pressed:
    __Change switchdirections to 1-switchdirections

    . . . . . . . . . . .

    If 'switchdirections' is a Boolean:

    When touch is pressed:
    __Change switchdirections to not(switchdirections)

Sign In or Register to comment.