jmp909 Posted October 24, 2015 Share Posted October 24, 2015 Hi, I've set up this demo showing how to paint a mask using a sprite ... I'd be interested to know if there's a better solution.. specifically I have to update my alphaMask every time it changeshttp://phaser.io/sandbox/dTgZMaFF/playfunction create() { phaser = game.make.sprite(0, 0, 'phaser'); chaos = game.make.sprite(0, 0, 'chaos'); chaos.scale.set(2); // make bitmap data size of stage bmd = game.make.bitmapData(chaos.width, chaos.height); // set our bitmapdata as the mask of our graphic bmd.alphaMask(chaos,bmd) // add our masked image to the stage game.add.sprite(0,0,bmd) // draw on mouse move game.input.addMoveCallback(move, this);}function move(pointer, x, y) { // draw our sprite to the bitmap bmd.draw('phaser',x,y) // update the mask bmd.alphaMask(chaos,bmd)}thanksj Link to comment Share on other sites More sharing options...
ramspeed Posted December 23, 2015 Share Posted December 23, 2015 Neat example! Can someone show me how to make that black mask an image that you erase through? Link to comment Share on other sites More sharing options...
Recommended Posts