How do I move an object acording to touch?

Get help using Construct 2

Post » Wed Feb 05, 2014 7:16 pm

I am making a shoot them up and need to move the ship like the dodonpachi ressurection and other shmup games.

basically, you're supposed to touch anywhere on screen and then move your finger while still touching. the sprite needs to imedeately move the same amount of pixels as the finger.

I really need this help,tx.
B
3
Posts: 8
Reputation: 191

Post » Wed Feb 05, 2014 8:22 pm

this video ilustrates better what I want. anyone know how I cana chieve this in construct2?

http://www.youtube.com/watch?v=agVmQzrcVjk
B
3
Posts: 8
Reputation: 191

Post » Wed Feb 05, 2014 8:34 pm

can you find the x position where you first touch the screen ? (and store this position maybe in a instance variable ?)

do something like while in touch find new touch x position (store this position)

find the difference between old touch x and new touch x position

offset your ship by same amount

set old touch to be the new touch

do it again while in touch
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
33
G
47
Posts: 1,194
Reputation: 30,812

Post » Wed Feb 05, 2014 8:37 pm

looks like simple drag and drop behaviour with offset.

either create a sprite on touch with drag and drop and pin it to the ship position sprite, or create offsetx and offsety variables and position the ship acording to touch.x-offsetx and touch.y-offsety.
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 Feb 05, 2014 8:48 pm

[QUOTE=LittleStain] looks like simple drag and drop behaviour with offset.

either create a sprite on touch with drag and drop and pin it to the ship position sprite, or create offsetx and offsety variables and position the ship acording to touch.x-offsetx and touch.y-offsety.[/QUOTE]

would drag and drop really work? doesn't drag and drop involve directly touching the sprite? I need to move it regardless of the touch point.

about these offsets variables, should they be global variables?
B
3
Posts: 8
Reputation: 191

Post » Wed Feb 05, 2014 8:58 pm

if you create a sprite at touch.x,touch.y with drag and drop behaviour, pin the ship to it and on touch end destroy the sprite.. should work..
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 Feb 05, 2014 9:08 pm

[QUOTE=LittleStain] if you create a sprite at touch.x,touch.y with drag and drop behaviour, pin the ship to it and on touch end destroy the sprite.. should work..[/QUOTE]

I think I understand it now, thanks a lot. this pinning thing, is it an event action like this: ship -> position -> set position acording to this touch.x, touch.y object?
B
3
Posts: 8
Reputation: 191

Post » Wed Feb 05, 2014 9:14 pm

I was actually thinking of using pin-behaviour for it..

You could also do the offset way, it's just preference..
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 Feb 05, 2014 10:00 pm

[QUOTE=LittleStain] I was actually thinking of using pin-behaviour for it..

You could also do the offset way, it's just preference..[/QUOTE]

I didn't know about the pin behaviour existence :p
B
3
Posts: 8
Reputation: 191

Post » Wed Feb 05, 2014 10:06 pm

move with touch example

RamPackWobble2014-02-05 22:09:25
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
33
G
47
Posts: 1,194
Reputation: 30,812

Next

Return to How do I....?

Who is online

Users browsing this forum: adamebastin, ketramtu18 and 8 guests