Jump to content

Help with masking


mokargas
 Share

Recommended Posts

Hey there all, I'm confused with masking

I have two layers (Phaser.Groups). The bottom layer contains some objects, the top layer contains a simple animated Phaser TileSprite. (Image attached, I've used a nautical analogy )

What I'm trying to do is punch a hole in the top layer, so you can see objects on the bottom layer. I have assumed a mask is the best way to do this. The mask also moves with the mouse pointer.

I am drawing the mask via graphics (basically just a white drawCircle of a fixed size), and applying it via the mask property on the top-most Tilesprite.

Unfortunately, when apply the mask to that top layer, it shows a circular portion of the top layer and I can see the entire bottom layer. Basically I need the inverse of that - is an inverted mask  possible?

idea.png

 

Link to comment
Share on other sites

I was going about this the wrong way (the "intuitive way").

The water layer actually needs to be on the bottom.

The items layer needs to be on top, and is then masked using a Graphics object

The seabed layer is also masked using the same Graphics object, placed behind the items and job done

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...