Picking Question

Get help using Construct 2

Post » Fri Oct 19, 2012 8:40 am

Hey there everyone, as the title states, I have a picking question...

I've got multiple instances of my object, and they all have a private variable, this variable is a different value for each instance, now, when two instances are next to each other, I need to make them average out their values with each other, and this needs to work for as many as their might be side by side.

if I have 3 instances (with their values showing) arranged like so:

7, 6, 2...

I need to have them all check with each other and become:

5, 5, 5...

any ideas?
Overlap at offset detects the side by side instances, but after that I can't seem to find a good way to select them, the instances are also created and placed randomly, so UID's are no good...

Thanks in advance.
Brent
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Fri Oct 19, 2012 8:54 am

Just wondering, is there a way to call for the UID of an object I'm detecting at offset? As I understand it, Overlap at Offset only picks the object that is checking for the overlap, not the object overlapped as well, if I could return the UID of the object being overlapped, then I could make it work
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Fri Oct 19, 2012 2:03 pm

Have you tried "pick nearest"?
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Oct 19, 2012 5:48 pm

No because there will be cases where there will be multiple instances that could be considered "nearest" at the same time, I need more precise control than that. I appreciate the reply however :)
B
64
S
8
G
9
Posts: 290
Reputation: 8,590

Post » Fri Oct 19, 2012 6:59 pm

http://dl.dropbox.com/u/5426011/examples15/average_values.capx

You can tweak how you define what side by side by changing the "select" sprite or tweaking event 4.

If you want to have only touching sprites count as side by side then make "select" have the same image as "sprite". Or if you want to do a distance calculation instead change event 4 to:
Pick all sprite
For each sprite
distance(select.x, select.y, sprite.x, sprite.y) <= 100

If you can pick an object you can get it's UID. In the case of your question you could save the uid of the object to a global var, check for overlapping at offset, and then use an inverted pick by uid to make sure you don't pick the original. That may not work in this situation of checking for objects of the same type, so you may want to use a detector object as I have in the example.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713


Return to How do I....?

Who is online

Users browsing this forum: christina and 6 guests