Puzzle: pieces that swap positions

haplo67haplo67 Member Posts: 38
edited April 2012 in Working with GS (Mac)
This is my problem:
a puzzle with 16 pieces in which the two selected pieces must to swap their position.
What I can do it?
Thanks!

Best Answer

  • scitunesscitunes Posts: 4,047
    Accepted Answer
    create the following integer game attributes:

    game.TouchCount
    game.X1
    game.Y1
    game.X2
    game.Y2

    In the puzzle piece prototype:
    create integer self attribute self.TouchState (0= not touched 1=touched First 2=Touched Second)

    When game.touchCount = 0
    ----when touch is pressed
    -------change game.X1 to self.positionX
    -------change game.Y1 to self.positionY
    ----When Touch is released
    -------change self.touchstate to 1
    -------change game.touchCount to 1

    New Rule: When game.touchcount = 1
    ----when touch is pressed
    -------change game.X2 to self.positionX
    -------change game.Y2 to self.positionY
    ----When Touch is released
    -------change self.touchstate to 2
    -------change game.touchCount to 2

    New Rule when game.TouchCount = 2
    -----Rule - When self.touchstate=1
    -------change - self.positionX to game.X2
    -------change - self positionY to game.Y2
    -----Rule - When self.touchstate=2
    -------change - self.positionX to game.X1
    -------change - self positionY to game.Y1
    -----Timer after .2 seconds (run to complete)
    --------change self.touchstate to 0
    --------change game.touchCount to 0

Answers

Sign In or Register to comment.