Added the sourceRect and maskRect parameters back into BitmapData.alphaMask as they were accidentally removed in 2.1 (thanks seejay92)

This commit is contained in:
photonstorm 2014-09-25 15:28:12 +01:00
parent 7f23438a75
commit 415c7fe578
3 changed files with 24 additions and 3 deletions

View file

@ -93,6 +93,7 @@ Version 2.1.2 - "Whitebridge" - in development
### Updates
* TypeScript definitions fixes and updates (thanks @clark-stevenson @englercj)
* Added the `sourceRect` and `maskRect` parameters back into `BitmapData.alphaMask` as they were accidentally removed in 2.1 (thanks seejay92)

2
build/phaser.d.ts vendored
View file

@ -1248,7 +1248,7 @@ declare module Phaser {
add(object: any): Phaser.BitmapData;
addToWorld(x?: number, y?: number, anchorX?: number, anchorY?: number, scaleX?: number, scaleY?: number): Phaser.Image;
alphaMask(source: any, mask: any): Phaser.BitmapData;
alphaMask(source: any, mask: any, sourceRect?: Phaser.Rectangle, maskRect?: Phaser.Rectangle): Phaser.BitmapData;
blendAdd(): Phaser.BitmapData;
blendColor(): Phaser.BitmapData;
blendColorBurn(): Phaser.BitmapData;

View file

@ -1066,11 +1066,31 @@ Phaser.BitmapData.prototype = {
* @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.
* @param {Phaser.Rectangle} [sourceRect] - A Rectangle where x/y define the coordinates to draw the Source image to and width/height define the size.
* @param {Phaser.Rectangle} [maskRect] - A Rectangle where x/y define the coordinates to draw the Mask image to and width/height define the size.
* @return {Phaser.BitmapData} This BitmapData object for method chaining.
*/
alphaMask: function (source, mask) {
alphaMask: function (source, mask, sourceRect, maskRect) {
return this.draw(mask).blendSourceAtop().draw(source).blendReset();
if (typeof maskRect === 'undefined' || maskRect === null)
{
this.draw(mask).blendSourceAtop();
}
else
{
this.draw(mask, maskRect.x, maskRect.y, maskRect.width, maskRect.height).blendSourceAtop();
}
if (typeof sourceRect === 'undefined' || sourceRect === null)
{
this.draw(source).blendReset();
}
else
{
this.draw(source, sourceRect.x, sourceRect.y, sourceRect.width, sourceRect.height).blendReset();
}
return this;
},