How to control an actor move by different combination?

kiralmhkiralmh Member Posts: 10
edited November -1 in Working with GS (Mac)
For example, if the player touch the iphone left area three time and right area one time then the actor will move to right a distance then stop , if the combination incorrect,then it won't move.
it is possible to make this function?

Comments

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Rules and attributes are your friends.

    First you can track the combination by using one attribute to contain it and another to count the number of presses.
    You can make an actor on the left side of the screen change the combination value by multiplying the existing value by 10 and adding 1.
    Similarly you can make an actor on the right half do the same but add 2.

    Why did I pick 1 and 2 to add to it? Its easier that way. They are just symbolizing that the left side was pressed(1) and the right side was pressed(2).

    For example if you pressed left side 3 times then right side once, the value of the combination value would be:
    Initially: 0
    First press: 0*10+1 = 1
    2nd press: 1*10+1 = 11
    3rd press: 11*10+1 = 111
    4th press: 111*10+2 = 1112

    With each press you can also increment the count for the number of presses.
    So when the number of presses is 4, it checks the combination value, and if equals 1112 then you can do your action.

    Example here: http://gamesalad.com/game/play/85039
    To download, right click the download button at the lower right of the game area and save the linked file. Then change that .game file to a .zip and unzip it.
Sign In or Register to comment.