Damla Eker

Dynamically created image masks

Recommended Posts

Hi all,

I need to display a large image and dynamically hide sections of it.

I already use masking to specify which parts should be displayed.

The code I use to achieve this is in the form:

this._topMask = game.add.graphics(0, 0);
this._topMask.drawRect(0, 170, game.width, vm.ActiveGameHeight - 320);
this.defaultGroup.mask = this._topMask;

This is useful in that it gives me a rectangle within which the image renders.

Now I need to dynamically block sections of that rectange and create areas that are not rendered.

Ideally, I would like to be able to create masks similar to the image below. I cannot use presaved images because the position of the rectangles change dynamically.

What is the most performance optimised way to achieve this in Phaser? (I am on version 2.4.4)

maskRectangle.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.