Moving the Character by Mouse/touch Dragging

Get help using Construct 2

Post » Wed Jul 03, 2013 7:06 am

Hello,

There are some games where, when you press and hold down the left mouse button and drag it across the level or screen, the player character follows it. Same occurs on mobile: you drag with your finger and the player character follows wherever your finger goes.

Does anyone know how to do this?

I can get the player character to move to mouse.x and mouse.y but it only moves it instantaneously.
B
4
Posts: 9
Reputation: 743

Post » Wed Jul 03, 2013 7:45 am

There are many ways to do this..
One important question is ofcourse, what kind of movement do you want?
platform, 8-ways or something totally different?

You shouldn't set the player position, but the direction of the movement of the player towards mouse.x, mouse.y
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jul 03, 2013 8:17 am

Right now, I have multiple movements: 8 direction (keyboard), pathfinding (mouse and touch).
B
4
Posts: 9
Reputation: 743

Post » Wed Jul 03, 2013 8:35 am

I'll give you a for instance, using bullet-behavior

set bullet angle towards mouse.x,mouse.y (if you are using touch, remember that touch.x and touch.y only have values while touching, so in that case it's easier to work with a sprite set to touch.x, touch.y (only while touching) and set angle towards that)
set bullet speed to whatever..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Wed Jul 03, 2013 6:21 pm

Thank you, I was able to do it. Unfortunately, because I have multiple ways to move, it messes up. But alone, the mouse drag works.
B
4
Posts: 9
Reputation: 743


Return to How do I....?

Who is online

Users browsing this forum: David181, istero, vaticant, webebiz and 2 guests