A way to tell if an object is obscured?

For questions about using Classic.

Post » Sun Jun 07, 2009 1:33 pm

I'm making a prototype where I want to have a lot, lot of objects on screen. A lot of those objects are unnecessary after a certain point, because they're obscured by objects in front of them. Is there any way to tell if an object is obscured?

Edit: Alternatively, I might be able to check if two of the same sprites are on the same x/y and have the same angle and perform an action on one, but I'm not sure how to do that.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Sun Jun 07, 2009 1:47 pm

No, there's no way to check if an object is entirely obscured by another. You'll have to come up with your own system.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,610

Post » Thu Sep 24, 2009 8:36 pm

[quote:23z26szy]"I might be able to check if two of the same sprites are on the same x/y and have the same angle and perform an action on one"[/quote:23z26szy]

use 2 families to separate both spites in own sol.

[quote:23z26szy]"Is there any way to tell if an object is obscured?" [/quote:23z26szy]
store width and height of object in pv, use a temp to loop thru each pixel to check if its obscured. or you can look at my cap here the example uses while loop so if your objects aren't too huge its ok.

or periodically you can create temp copy sprite that starts in the center and expands until its the original sprites size (as long as its overlapping both original and another sprite, otherwise its destroyed) and when it reaches original size, destroy them both.. because its completely covered.

with that last example. you should have a 1 px sprite in a contrainer with your "overlapperer" and always have the 1 px sprite move in another direction 1 px away from the overlapperer each time it overlaps the overlapperer. the overlapperer expands its width/height to w/e direction the 1 px sprite moves. if it expands and doesn't overlap them all (original sprite, another sprite and 1px), its destroyed.... i can come back with pics if you didnt get that.

the last method may be faster than per pixel but its not perfect. per pixel would seem better if its not going to trigger often.

overlapperer :mrgreen:
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Thu Sep 24, 2009 9:16 pm

Thanks for the ideas. I'll give them a shot.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Fri Sep 25, 2009 10:46 am

Per-pixel checking is going to be very slow. If object is fully obscured, then you can solve it faster with the bounding box check. Partially obscured objects are still partially visible!
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests