Skip to content

Commit e5810f1

Browse files
committed
Added DisplayObject.transformCallback
1 parent f9d899b commit e5810f1

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

src/pixi/display/DisplayObject.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ PIXI.DisplayObject = function()
2727
*/
2828
this.scale = new PIXI.Point(1,1);//{x:1, y:1};
2929

30+
/**
31+
* The transform callback is an optional callback that if set will be called at the end of the updateTransform method and sent two parameters:
32+
* This Display Objects worldTransform matrix and its parents transform matrix. Both are PIXI.Matrix object types.
33+
* The matrix are passed by reference and can be modified directly without needing to return them.
34+
* This ability allows you to check any of the matrix values and perform actions such as clamping scale or limiting rotation, regardless of the parent transforms.
35+
*
36+
* @property transformCallback
37+
* @type Function
38+
*/
39+
this.transformCallback = null;
40+
41+
/**
42+
* The context under which the transformCallback is invoked.
43+
*
44+
* @property transformCallbackContext
45+
* @type Object
46+
*/
47+
this.transformCallbackContext = null;
48+
3049
/**
3150
* The pivot point of the displayObject that it rotates around
3251
*
@@ -493,8 +512,6 @@ PIXI.DisplayObject.prototype.updateTransform = function()
493512
wt.d = c * pt.b + d * pt.d;
494513
wt.tx = tx * pt.a + ty * pt.c + pt.tx;
495514
wt.ty = tx * pt.b + ty * pt.d + pt.ty;
496-
497-
498515
}
499516
else
500517
{
@@ -514,6 +531,13 @@ PIXI.DisplayObject.prototype.updateTransform = function()
514531

515532
// multiply the alphas..
516533
this.worldAlpha = this.alpha * this.parent.worldAlpha;
534+
535+
// Custom callback?
536+
if (this.transformCallback)
537+
{
538+
this.transformCallback.call(this.transformCallbackContext, wt, pt);
539+
}
540+
517541
};
518542

519543
/**

0 commit comments

Comments
 (0)