Multiple objects instances tracking

Get help using Construct 2

Post » Sat Jan 28, 2012 1:16 am

I'm creating objects every second, two types, both of them spawns (potentially) infinite objects:


Is touching objectOne
   - Set Touched = 1
   - set t_TouchX_s = Touch.X
   - set t_TouchY_s = Touch.Y

On touch end && Touched == 1
   - Set Touched = 0
   - set t_TouchX_e = Touch.X
   - set t_TouchY_e = Touch.Y
   - objectOne Physics Force distance(t_MouseX_s, t_MouseY_s, t_MouseX_e, t_MouseY_e) toward (t_MouseX_e, t_MouseY_e)


This applies the force to ALL objects of that type. How can I make it that it applies the force only to the one I originally touched. I understand that I could set the UID in a variable, but that would mean destroying the multi touch! And things gets a lot more complicate since I have two types of objects.

Anyone has a solution?

Thanks0plus12012-01-28 01:17:10
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Sat Jan 28, 2012 11:32 am

Bump?
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Sat Jan 28, 2012 11:47 am

it is allways a very good idea to provide your CAPX....
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Sat Jan 28, 2012 9:04 pm

I don't have a multi-touch device so I can't fully test this but here is an idea of how to distinguish between multiple touches. It uses sprites to keep track of the positions of the touches and what objects were initially touched.

http://dl.dropbox.com/u/5426011/examples%208/multitouch.capx

Edit: Since I can't test it I can't be sure but you may need to add a "for each Sprite" condition to the top of event 4.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Sat Jan 28, 2012 10:00 pm

I think for a "flick" type of control you could just use an instance variable, like sprite.variable("wastouched")= 1, sprite go to this vector.
Then you would need another variable to tell if the object was still moving, and then once it stops moving set wastouched to 0.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767


Return to How do I....?

Who is online

Users browsing this forum: chcteacher, Televangelist and 27 guests