How can I use continuous Touch to move a Sprite?

Get help using Construct 2

Post » Thu Feb 27, 2014 6:26 am

I would like my player sprite to always be located exactly where the user is touching the screen. No delay. Instant movement to the user's touch. Instantly follow the user's finger as it slides across the screen.

With the Mouse object this works when moving the mouse - by using Mouse -> Cursor is over Background. My sprite follows the mouse cursor exactly.

With the Touch object I can't seem to get this to work. I have tried:
    Touch -> Is in touch
    Touch -> Is touching Background
    Touch -> On any touch start
    Touch -> On any touch end
All of these seem to result in the sprite moving to my finger when I place it on the screen - but it doesn't track me if I keep my finger on the screen and slide it around. I have to lift my finger off the screen, and place it down on the screen again to move to a new location.

What Touch conditions or similar approach can I use so that the user does not ever have to lift their finger from the screen while playing the game?

Thanks!
B
4
Posts: 10
Reputation: 220

Post » Thu Feb 27, 2014 8:01 am

Image

works for me on android.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,892

Post » Sun Mar 09, 2014 7:08 pm

I'm trying myself, i don't get it. I see your screenshot, but. i am trying to set it so, a user touches/or keeps touching object and it. switches direction and keep the character in continuous movement.
B
17
S
4
Posts: 20
Reputation: 1,245

Post » Wed Mar 12, 2014 5:33 am

@Aphixe the solution above is to teleport your character to wherever you tap/touch. If you want the character to move continuously, you will need something like:
Touch | Is in touch
System | distance(Player.X, Player.Y, Touch.X, Touch.Y) > 300*dt

Then:
Player | Move 300*dt pixels at angle angle(Player.X, Player.Y, Touch.X, Touch.Y)
B
8
S
3
G
1
Posts: 135
Reputation: 2,209

Post » Wed Mar 12, 2014 7:41 am

Why not drag n drop?
B
29
S
11
G
2
Posts: 696
Reputation: 5,171

Post » Fri Mar 14, 2014 2:50 am

You can also use:

Is in touch:
- set Player.Angle to touch.X, touch.Y
- move (x) Pixel forward
B
22
S
6
G
2
Posts: 185
Reputation: 3,632

Post » Fri Mar 14, 2014 9:13 am

irina wrote:Why not drag n drop?

Nah.It won't work.OP want to teleport it to where he touches.
I will not let you reach the sisters
Nature Forums
B
11
S
5
G
2
Posts: 496
Reputation: 2,306


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 26 guests