How do I make an object invisible were it doesn't overlap

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I'm creating a puzzle

    where a few long sprites (let's call them l1, l2, l3, and l4) are scrolled vertically

    through a few small transparent windows

    in an otherwise opaque image. (a single sprite called b1)

    The problem is the long sprites are overlapping, so they show up in more than one window.

    I can't solve the problem using Z-order, since there is always at least one sprite that is being covered by the others

    no matter what the Z-order.

    I've already created transparent sprites that mark the location of the windows. (lets call them t1, t2, t3 and t4)

    I want only the part of the long sprite that is in the window to be visible,

    hence I want only that part of the long sprite that is overlapping with the transparent window sprite

    to be visible for each pair of sprites.

    So I want l1 to be visible only were it is overlapping t1, not were it's overlapping t2, t3 or t4.

    Same thing with l2 and t2, l3 and t3, etc.

    (And no, I can not prevent l1 from overlapping t2, t3, or t4.)

    How can I do this?

    So far I've tried all combinations of blend modes, Z-orders, effects and whatnot I can think of and nothing is working.

    I suppose I could break up l1, l2, etc. into several smaller sprites, pin them together, and hide each one once they are no longer overlapping t1, t2 etc. but it's a lot of work since they are very long sprites and there's a lot of overlap to avoid.

    If only there was a blend mode like destination in but were the alfa in the image ontop actually made the underlying image go transparent instead of black....

  • without seeing your capx or a video I don't know for sure ( not that I'm any better at figuring things out than you).

    However, could you put the long sprites on a different layer and just hide part of the layer?

  • OR what if you created 2 separate sprites? 1 long sprite and 1 short sprite. Just destroy ( or set invisible) the long sprite and pin the short sprite to the same location?

  • Z-order doesn't solve the problem. (and that's all that layers are essentially)

    I need the long sprites so I can scroll them vertically through the windows,

    I'm not sure what the short sprites are you are referring to.

    Please refer to the sprites in question by name. (l1, t1, etc.)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't really understand what's going on, but it looks like your are looking for masks, I'm also not sure if they exist in C2.

    You should try to search for masks in C2, maybe there's a plugin or something you could use.

  • Masking is simple in C2. Use Destination Out and set that layer to Force Own Texture. Unless I missed what you were looking for...

  • Setting the layer to Force Own Texture doesn't solve anything I'm afraid.

    For instance l2 shows up in the transparent windows in b1 covered by t1, t2 and t3.

    I could make l2 show up only in t2, by putting t1 and t3 above t2 (below b1) in the Z-order

    and use the copy blend mode (for instance)

    but then I'd have to put l1 above t1, which would put it above t2 as well,

    and then we have overlap again.

    If I could only use paradoxical Z-ordering (c above a above b above c) it wouldn't be a problem...

    Or if there was any other way to make t1 mask l2 but not l1, while at the same time making t2 mask l1 but not l2.

    But as far as I know there is no way to make a sprite mask one other sprite only.

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