pick nearest always picks first instance

Get help using Construct 2

Post » Thu Jan 29, 2015 10:04 am

i dispair.... either i'm stupid or construct handle loops very strange.

i just want to replace e.g 5 sprites with a different one but only when the distance between the sprites > 100
the event "pick nearest" always pick the first instance and not the nearest.

the action "set txt to" on line 32 always display the x from the first instance.
line 31, works fine. every run of the loop it picks a different instance

any idea?
You do not have the required permissions to view the files attached to this post.
Posts: 42
Reputation: 463

Post » Thu Jan 29, 2015 11:38 am

When you spawn a stone inside the loop then you can't pick it until that event finishes. (You can pick a newly created object by UID only). Those new stones you spawn won't be picked by the 'Pick all' condition.

I'm guessing you have one stone on the layout at the start and you call this function to create more but it's only able to pick that first stone. You'll have to try a different approach.

For example, you could spawn all the stones first, in a different event. Create all stones at (-1000, -1000) with boolean flag placed = false. Then you can have your loop that would be almost the same but instead of spawning stones it moves one of the unplaced stones to the correct position.
Posts: 1,520
Reputation: 25,790

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests