seejay92 Posted September 25, 2014 Share Posted September 25, 2014 Hi guys, First time poster and novice with Phaser - Just a quick question about the bitmapdata alpha masks in 2.1.1... I've been using 2.0.7 for the last few months and loved the update to Bitmapdata via Pixi 1.6.0, allowing you to use a sourceRect and maskRect to define the size/location of your alpha masks and bmd I've just updated to 2.1.1 this morning and the option for these two arguments for alphaMasks appears to have been removed again according to the definitions file. I've not noticed anything in the changelogs since 2.1.0 to suggest what has happened - is there any work around to define these arguments again, or am I just being stupid and missing the obvious? Many thanks! Cameron Link to comment Share on other sites More sharing options...
rich Posted September 25, 2014 Share Posted September 25, 2014 Hmm it's still in the code: /** * Draws the image onto this BitmapData using an image as an alpha mask. * * @method Phaser.BitmapData#alphaMask * @param {Phaser.Sprite|Phaser.Image|Phaser.Text|Phaser.BitmapData|HTMLImage|HTMLCanvasElement|string} source - The source to copy from. If you give a string it will try and find the Image in the Game.Cache first. This is quite expensive so try to provide the image itself. * @param {Phaser.Sprite|Phaser.Image|Phaser.Text|Phaser.BitmapData|HTMLImage|HTMLCanvasElement|string} [mask] - The object to be used as the mask. If you give a string it will try and find the Image in the Game.Cache first. This is quite expensive so try to provide the image itself. If you don't provide a mask it will use this BitmapData as the mask. * @return {Phaser.BitmapData} This BitmapData object for method chaining. */ alphaMask: function (source, mask) { return this.draw(mask).blendSourceAtop().draw(source).blendReset(); }, Link to comment Share on other sites More sharing options...
seejay92 Posted September 25, 2014 Author Share Posted September 25, 2014 Hi Rich, Nice to speak to you! Yeah it seems alpha masks are still in but have just lost their 3rd and 4th arguments between the last phaser release, which allowed you to use a rectangle to define the size and co-ords of your mask - Although I may just be missing something, I'm pretty much a newbie to javascript. For my game I'm using resized images as the masks which used the rectangles to make the change, but I know the update added the ability to use sprites as masks, maybe there's a way of just using sprites instead. This is the definition files for the releases i have, c and d from what I recall was the references to the rectangles - /* Phaser v2.1.1 - http://phaser.io - @photonstorm - © 2014 Photon Storm Ltd. */ alphaMask: function (a, { return this.draw(.blendSourceAtop().draw(a).blendReset() /* Phaser v2.0.7 - http://phaser.io - @photonstorm - © 2014 Photon Storm Ltd. */ alphaMask: function (a, b, c, d) { ("undefined" == typeof b || null === && (b = this); var e = this.context.globalCompositeOperation; "undefined" == typeof d || null === d ? this.draw( : this.draw(b, d.x, d.y, d.width, d.height), this.context.globalCompositeOperation = "source-atop", "undefined" == typeof c || null === c ? this.draw(a) : this.draw(a, c.x, c.y, c.width, c.height), this.context.globalCompositeOperation = e, this.update(), this.dirty = !0 }, Thanks so much for your help, it's greatly appreciated! Cameron Link to comment Share on other sites More sharing options...
rich Posted September 25, 2014 Share Posted September 25, 2014 Ahh yes, gotcha. You could do it manually I guess, or wait for this to hit master? https://github.com/photonstorm/phaser/commit/415c7fe57811ba50e5d8232c43d80b914080b23a Link to comment Share on other sites More sharing options...
seejay92 Posted September 25, 2014 Author Share Posted September 25, 2014 Cheers Rich, I'll try manually first but may need to wait for master Thanks for your quick fix! Link to comment Share on other sites More sharing options...
Recommended Posts