How to do this kind of drag and drop :

Get help using Construct 2

Post » Thu Sep 24, 2015 8:46 pm

Hi everyone

I would like to do this kind of drag and drop (screen capture below from Sky Force 2014).
Player can drag a random point of the screen, the object will always follow the gesture. That way the object is not hidden by the finger while dragging. If somebody has an idea how to do it, it would be cool.

Image

Thanks
Image
B
9
S
1
Posts: 22
Reputation: 586

Post » Thu Sep 24, 2015 10:46 pm

Create an object and every tick, set it to mouse.x-50 mouse.y-50 position (or touch position).

This will act as the position your object will follow, to the left and above the mouse.

When mouse is down, set the object you wish to move to the position of the object you just created. Have the object initial state to invisible.

Basically, create a new object that is offset from the mouse, by the distance you want. Then have your object follow this, instead of the mouse, or touch in your case.

Hope it helps.
B
9
S
3
Posts: 104
Reputation: 1,033

Post » Fri Sep 25, 2015 10:12 am

or , very slightly adapted from demo space shooter that comes with construct 2, reducing the need for a second (invisible) sprite and also the every tick.

https://goo.gl/nA76uj
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,882

Post » Fri Sep 25, 2015 11:27 am

@Frostein. It's not exactly that beacuse in my case, distance from the mouse should be variable. Depending of the finger position the player choose (and this postion is changing during the game). In other words anywhere he touchs the screen, the object should start to move from it's current position.

I found a visual example : https://www.youtube.com/watch?v=XdkOWUZFXHk It's often used for mobile shoot em up.
Image
B
9
S
1
Posts: 22
Reputation: 586

Post » Fri Sep 25, 2015 12:08 pm

in that case
change above to something like

https://goo.gl/UXY4mh

which gives

https://dl.dropboxusercontent.com/u/143 ... index.html

there are, of course, other ways...
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,882

Post » Fri Sep 25, 2015 3:02 pm

Thank you
Image
B
9
S
1
Posts: 22
Reputation: 586


Return to How do I....?

Who is online

Users browsing this forum: 25games, Artcadev, Ashley, mcscooter, Soluna Software and 29 guests