How do I 'Choose' the nearest object?

Get help using Construct 2

Post » Thu Jun 02, 2016 2:51 am

Message: helpdastudent can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hi.. I'm totally new, needed some help to complete my first game.

This game that I am making, http://imgur.com/1ZJaEWr

It's a easy drag and drop objects to the correct areas, (example Box1 is AppleBox, Box2 is OrangeBox), drag drop the Orange into the correct box.

Short Version:
There are scores, dropping to the correct box gives +5, and the wrong box -5, however, if you were to drop in between of both box, the score will be 0 (+5 and then -5).
What I wanted is, how do you choose the nearest object, like, if the Orange is nearest to the OrangeBox, drop in the OrangeBox instead of both (when it is in the middle, or somewhat touching both box)

What I'm doing/currently have
Orange on dragdrop drop and Orange is overlapping OrangeBox, System Add 5 to score
Orange on dragdrop drop and Orange is overlapping AppleBox, System Subtract 5 to score

More details:
When placed in the wrong box, the object will destroy and create another one at the "cart",
which putting in the middle, created one orange in the orangeBox, but have a score of 0, and the orange is re-created at the "cart" again, this is a huge problem for me. ):

(Maybe I shouldn't be using overlapping? or is there a choose to overlap the nearest box, or anything)
P.S. I am totally new, just started learning this software a few days ago.

If possible, would like to see an example, or a clear explanation of a solution/solution that work
B
5
S
1
Posts: 6
Reputation: 337

Post » Thu Jun 02, 2016 4:35 am

help please.. anyone..?
B
5
S
1
Posts: 6
Reputation: 337

Post » Thu Jun 02, 2016 4:40 am

On overlap should work fine.. sounds like you have something else going wrong.

If I was making this I would use 2 invisible sprite "zones" one covering each box and use the on-overlap condition. I would however use a double condition test for overlapping both (ie. is overlapping spriteOrange and spriteApple).

You could get more complex and grab the orangeBox.X and the AppleBox.X and then test against their values to determine which one is closer to the apple.x or orange.x but for a simple project like this I would just use overlapping sprites.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
66
S
17
G
8
Posts: 637
Reputation: 9,370

Post » Thu Jun 02, 2016 4:48 am

Yah that's what I did, (without the double condition test of overlapping both), there is a image link to show my project.

and yes, I kinda need/want that distance test to see which one is closer and then apply it to the box

edit: i am using invisible overlapping sprites. like i mentioned above, if you overlap both boxes, it activate its event for both boxes (score +5 then -5)
B
5
S
1
Posts: 6
Reputation: 337

Post » Thu Jun 02, 2016 8:20 am

Pop the capx ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests