Getting myself confused...

DimensionGamesDimensionGames PRO Posts: 993
edited November -1 in Working with GS (Mac)
Iv been doing a bit of work on a new project, I have made a mistake and I know its really simple but Im struggling to solve it here is the current code for one of the actors:

Actor receives event touch is pressed....attribute game.walk/notwalk is false.
change attribute: game.walk/notwalk to true.

Attribute game.walk/notwalk is true
change attribute self.motion.linear to 100

Actor receives event touch is pressed....attribute game.walk/notwalk is true
change attribute game.walk/notwalk to false

attribute game.walk/notwalk is false
change self.motion.linear to 0.

Currently can't get this to work so when pressed it stops moving and pressed again starts moving.

Any help would be greatly appreciated.

Cheers.

Comments

  • ChobbifaceChobbiface PRO Posts: 491
    Make a game attribute (integer or real) called walk/notwalk or whatever you want to call it.

    In your actor make a rule:

    When touch is pressed.... change attribute game.walk/notwalk to (game.walk/notwalk+1)%2

    Make another rule in same actor:

    When game.walk/notwalk = 1.... change attribute self.motion.linear velocity X to 100.

    Then in otherwise section of same rule put:

    change attribute self.motion.linear velocity X to 0.

    Hope that helps
Sign In or Register to comment.