Jump to content

How to mask a region of the screen?


PadreMontoya
 Share

Recommended Posts

Hello,

 

I'm working on a match-3 game where blocks "fall in" from the top of the board, rather than just "appear" in the top-most space.

 

What I'd like to do is dynamically create a BitmapData mask that is in the shape of the 8x8 board and attach it to the group.  This way any blocks that drop in outside the boundary of the board can't be seen until they slide in.

 

 

It seems like the only way to do this would be to create a mask for every sprite that is dropping in, and dynamically adjust it every refresh.  Either that or maybe crop new blocks as they are dropping in.

 

Is there a better way to do it?

post-10261-0-53958200-1411007382.png

Link to comment
Share on other sites

Use a mask on the board itself, not the sprites. You can use Phaser.Graphics for a mask - so create the shape you need using Graphics commands, fill it and then set it to be the mask for the board. Then anything that is a child of the board will automatically be masked off.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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