Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: 4ppleseed on October 08, 2013, 06:50:44 PM

Title: Touch Object + Swipe together in one motion?
Post by: 4ppleseed on October 08, 2013, 06:50:44 PM
Hi all,
I'd like to be able to touch a cube and keeping my finger on it to swipe (up, down, left or right) and the cube move in that direction. The problem is I touch the object (using Touch Object) and then have to let go and then swipe the object to make it move. I thought it was just bad logic on my behalf at first but as I can't store the object in the swipe, I'm wondering if it's possible now?

Thanks.
Title: Re: Touch Object + Swipe together in one motion?
Post by: jeanfabre on October 09, 2013, 01:47:09 AM
Hi,

 dragging is totally possible:


http://hutonggames.com/playmakerforum/index.php?topic=1286.msg7149#msg7149

also, for general touch management, I recommand using touch.input.

https://hutonggames.fogbugz.com/default.asp?W961

with this, touch gestures and events becomes very easy.

bye,

 Jean
Title: Re: Touch Object + Swipe together in one motion?
Post by: 4ppleseed on October 09, 2013, 05:40:03 PM
EDIT:
Ahhhh, it's Touches.Charge! I see, a single touch is a 'charge'.

Jean, how do I go from a charge to a drag and work out which direction the player dragged in? It's the Delta bit right? But I don't know how to set it up. I think I set up the Delta as a Vector2 variable but how do I compare Position to Delta and turn it into an 'up' 'down' 'left' or 'right' event?


For example I have 8 cubes on screen, I want to touch on one and drag up and it moves that one cube 40 on the Y - all in one motion.

Thanks!
Title: Re: Touch Object + Swipe together in one motion?
Post by: jeanfabre on October 10, 2013, 03:02:11 AM
Hi,

 to get the "build up" of a drag, meaning the total drag since start ( or the magnitude of the drag) you need to add the delta on each frame during the drag. So you have a fsm float called "total drag" or something and you add the delta to that "total drag".

bye,

 Jean
Title: Re: Touch Object + Swipe together in one motion?
Post by: 4ppleseed on October 10, 2013, 04:58:33 AM
Sorry Jean, I mean more like, how do I tell which direction the drag was in?

I hold on a cube and drag up = up event happens.
I hold on a cube and drag left = left event happens
etc
Title: Re: Touch Object + Swipe together in one motion?
Post by: jeanfabre on October 10, 2013, 05:05:39 AM
Hi,

you have global events like

INPUT TOUCHES / SWIPE
INPUT TOUCHES / SWIPE DOWN
INPUT TOUCHES / SWIPE LEFT
INPUT TOUCHES / SWIPE RIGHT
INPUT TOUCHES / SWIPE UP


https://hutonggames.fogbugz.com/default.asp?W961

bye,

 Jean
Title: Re: Touch Object + Swipe together in one motion?
Post by: 4ppleseed on October 10, 2013, 12:42:29 PM
Thanks, I'll give them a go and feedback :D