Jump to content

Alpha mask with x and y shift and rotation


rastarez
 Share

Recommended Posts

Hi All

 

I would like to do a simple alpha mask but be able to offset the masked picture so that it is centered in the mask since the picture that is being masked is dynamic and can change positions. 

 

Any recommendation ?

 

Thanks 

 

Rz

Link to comment
Share on other sites

Interesting question to those who know better. Which is better, use mask or not to use mask if possible? That is, is it better for performance to have sprite on top another to mask, instead of masking one to be put on top?

 

In other words.. You have a sprite you want to mask, the sprite can change position and mask should stay at same position. Thus masking Phaser.Group seems the first solution. However, if you can arrange your sprites so that you draw another sprite on top and "hide" the parts which need to be masked out, would this have better performance when you can just get away with simple z-indexing?

 

Seems obvious that z-index is better, but I have not tested this yet.

Link to comment
Share on other sites

I'd estimate in most cases masking incurs a greater performance penalty than the overdraw associated with 'framing' the object with other objects, however without any conclusive testing I can't be sure how much, or even whether that is actually the case. It will also likely depend on the size of the object being masked, and the performance will be non-trivial to predict in WebGL compared to Canvas as I suspect the method is different depending on which one you use (hardware masking in WebGL vs the pixel blitting in Canvas).

 

Perhaps someone should write some tests and find out more?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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