How to create drag gestures

poopdecksweeperpoopdecksweeper Member Posts: 180
edited May 2012 in Working with GS (Mac)
I am looking for two formulas: 1. Get the distance from where touch is pressed and touch is released.
2. Get the distance from where touch is pressed to where touch is dragged, but not yet released.

I will be constraining these amounts to an actor: 1. when dragging constrain self width and height to touch.
2. When released set actor width and height to distance of drag.

Any help would be greatly appreciated

-PDS

Answers

  • PhoticsPhotics Member Posts: 4,172
    The magnitude function is used for calculating the distance between two points.

    When touch is pressed,
    save X1 to attribute
    save Y2 to attribute

    When touch is released
    save X2 to attribute
    save Y2 to attribute

    magnitude((X2-X1),(Y2-Y1))

    This formula could be used while the touch is active. Instead of using the release data, X2 & Y2 would be the touch data. (It's easier with a mouse, as there's only one touch point to worry about.)
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    How can I save the amount of magnitude that there is between points (x2-x1),(y2-y1)?

    I would like an actor's self.size.width to be constrained to this amount?
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    I have all of those attributes already. but I don't know how to get the magnitude of the press to equate to the self.size.width of an actor that I am pressing (a box). The game is going to be a bridge building game. The car starts at the left, and you have to either tap on the screen to make boxes fall to make a bridge, or when you have the special power up you can tap one side of the screen and drag it to the other side where the goal is. How?
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    also @tshirtbooth: I am trying to use your JB2.49 template with the buckets and the balls, and I am trying to change the scene size, but when I do that and the ball goes off screen It cannot be launched again.

    I know that I need to mess with the distancefrompouse attribute, but I can't quite wrap my head around it.
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    thanks for the help btw
  • poopdecksweeperpoopdecksweeper Member Posts: 180
    Thanks again TSB. You already know how valuable you are, so I won't say it.









    okay maybe I will......Extremely valuable! There wouldn't be this big a following without you.

    -PoopD
Sign In or Register to comment.