rastarez Posted May 16, 2014 Share Posted May 16, 2014 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 More sharing options...
stasuss Posted May 17, 2014 Share Posted May 17, 2014 PIXI.DisplayObjectContainer === Phaser.Group -> mask property. Link to comment Share on other sites More sharing options...
jouniii Posted May 21, 2014 Share Posted May 21, 2014 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 More sharing options...
lewster32 Posted May 21, 2014 Share Posted May 21, 2014 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 More sharing options...
Recommended Posts