seejay92

Bitmap Data AlphaMasks

Recommended Posts

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?  :P

 

Many thanks!

 

Cameron

Share this post


Link to post
Share on other sites

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();    },

Share this post


Link to post
Share on other sites

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 

 

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.