Saltallica Posted June 2, 2018 Share Posted June 2, 2018 Is it possible? For example - I have a sprite I want to add holes to. In this case, it's a blimp. A player can hit the blimp multiple times. Each time the blimp is hit, a hole should be placed in the spot where the hit occurred. The base mask sprite: The hole sprite: Some psuedo code: //full blimp mask this.mask = new PIXI.Sprite(blimpMask); this.sprite.addChild(this.mask); this.sprite.mask = this.mask; //inside my hit testing methods //add a child sprite to the mask sprite var localPos = this.sprite.toLocal({x: pos.x, y: pos.y}) var hole = new PIXI.Sprite.fromImage('/img/blimp-hit.png'); this.mask.addChild(hole); hole.position.x = localPos.x; hole.position.y = localPos.y; hole.scale.x = 0.5; hole.scale.y = 0.5; hole.anchor.x = 0.5; hole.anchor.y = 0.5; So, if there were two holes added to the mask sprite, they would be added as children of the main mask: I would expect the composite sprite, when set as a mask, to have holes as outlined above, but the children sprites are never accounted for when the parent sprite is set as a mask. Is there a definitive way to make a dynamic mask that is comprised of multiple sprites? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted June 2, 2018 Share Posted June 2, 2018 It is not a newbie material. Use renderTexture to store composite mask before you render the stage. The trick you are talking about is possible with pure container/layer manipulation, but you need to study the plugin first: https://github.com/pixijs/pixi-display/blob/layers/bin/pixi-layers.js , use layer "getRenderTexture()" method to get temporary screen-size render texture for your blimp: https://pixijs.io/examples/#/layers/lighting.js Quote Link to comment Share on other sites More sharing options...
Saltallica Posted June 2, 2018 Author Share Posted June 2, 2018 Thanks - I'll dig in! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.