How to swipe to move in intermediate directions

ChucklingMonkeyChucklingMonkey Member Posts: 92
edited November -1 in Working with GS (Mac)
Hi,

How would I make it so when you swipe Up/right the player would move that way. Same with Up/ left because I need my player to be able to jump on platforms.

Thanks

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    Are you asking how to determine the swipe angle?

    You would need four attributes to detect the the x and y of the touch and release. (Choose "real" as the attributes' type.

    Then you can get the angle with:

    vectorToAngle( self.myReleaseX - self.myTouchX , self.myReleaseY - self.myTouchY )
  • ChucklingMonkeyChucklingMonkey Member Posts: 92
    RThurman said:
    Are you asking how to determine the swipe angle?

    You would need four attributes to detect the the x and y of the touch and release. (Choose "real" as the attributes' type.

    Then you can get the angle with:

    vectorToAngle( self.myReleaseX - self.myTouchX , self.myReleaseY - self.myTouchY )

    Sorry but do I make a Change Attribute? What is VectorTo ANgle
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    VectorToAngle(x,y) is a way to find out the angle between one one object and another. You should probably find some info on it before you continue .

    Do do use change attribute -- here is how.
    You could make an attribute called something like "mySwipeAngle" or whatever. Set it to be of type "real".

    Then I suppose you could have a big background actor with the following behaviors:

    When touch is pressed:
    Change Attribute: self.myTouchX To: game.Mouse.Position.X
    Change Attribute: self.myTouchY To: game.Mouse.Position.Y

    When touch is released:
    Change Attribute: self.mySwipeAngle To: vectorToAngle(game.Mouse.Position.X - myTouchX, game.Mouse.Position.Y - myTouchY)

    Make sure to use the drop down menus in the expression editor to create the change attribute behaviors. (Don't just type them in.)

    Then you can do what you want with the swipe angle!
Sign In or Register to comment.