SOLVED : How to see if there is an object BELOW

Get help using Construct 2

Post » Sun Jul 15, 2012 7:09 am

I am placing structures on my game map via a click event. So when you are ready to put an item down it should not be on TOP of another object.

For example you cannot build 2 towers in the same position.(x)

I can check to make sure that it is not overlapping and that works fine. But if I hover over another structure ( it is not overlapping ) then I can build the structure there : ) So.... basically I need to see if there is another structure BELOW the mouse : )

Any thoughts? Maybe in the morning I will get up and I will see it, but at 1 a.m. it is eluding me :)


sparkdad2012-07-15 21:10:14
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

Post » Sun Jul 15, 2012 8:58 am

That's what families are for! Buildable objects should be in a family, then you can simply do this:

+ Mouse is not over Buildables
> Do stuff

If you are dragging objects, make sure to filter that one out first before checking for other objects. Can be done with control variables; assign a variable whenever you pick an object up and clear it whenever you place it.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Jul 15, 2012 7:42 pm

It is not a MOUSE OVER....

It is a "MOUSE ABOVE"



eg.




                                X <-- Mouse Locaiton




                             TOWER
-------------------------------------------------------------------------

Does that make sense?

If the mouse is above ( Y axis )
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

Post » Sun Jul 15, 2012 8:11 pm

How about comparing Tower.Y with Mouse.Y?

If (Mouse.Y < Tower.Y) the mouse is above the tower.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Sun Jul 15, 2012 8:13 pm

When you place a tower does it get placed where you clicked or does it drop down to the ground level?

You could use an invisible sprite as a detector. Make it as wide as the tower and use some high number for the height. Then position it to the mouse and check it for overlaps with other towers.
B
79
S
24
G
54
Posts: 4,743
Reputation: 40,749

Post » Sun Jul 15, 2012 8:19 pm

It drops to ground level. Here is the file to see the project.

https://docs.google.com/open?id=0B5puA55FudSeVmpITDZ2dFNsT1E
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

Post » Sun Jul 15, 2012 9:09 pm

SOLVED: I used RoJo Hounds invisible sprite! Thanks!
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

Post » Tue Mar 05, 2013 12:47 pm

hello there,

could somebody tell me how can I do a procedural game like SKI SAFARI ( https://www.youtube.com/watch?v=i6mz4Nt6BPk )https://www.youtube.com/watch?v=i6mz4Nt6BPk is there any template or something else?

thanks for your help
B
3
Posts: 9
Reputation: 343


Return to How do I....?

Who is online

Users browsing this forum: anty21ro, Magistross, PavleNikolic and 24 guests