A way to tell if an object is obscured?

This forum is currently in read-only mode.
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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.

  • 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.

  • [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"

    use 2 families to separate both spites in own sol.

    [quote:23z26szy]"Is there any way to tell if an object is obscured?"

    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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks for the ideas. I'll give them a shot.

  • 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!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)