Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package HTools.Starling {
- import flash.geom.*;
- import starling.core.RenderSupport;
- //import starling.core.starling_internal;
- import starling.filters.FragmentFilter;
- import starling.utils.MatrixUtil;
- //use namespace starling_internal;
- public class DisplayObjectProxy extends DisplayObject {
- public var real:DisplayObject;
- /** Helper objects. */
- private static var scratchMatrix:Matrix = new Matrix();
- private static var scratchPoint:Point = new Point();
- public function DisplayObjectProxy() {
- }
- /** @inheritDoc */
- public override function getBounds(targetSpace:DisplayObject, resultRect:Rectangle = null):Rectangle {
- resultRect ||= new Rectangle();
- resultRect = real.getBounds(targetSpace, resultRect);
- return resultRect;
- }
- /** @inheritDoc */
- public override function hitTest(localPoint:Point, forTouch:Boolean = false):DisplayObject {
- if(forTouch && (!visible || !touchable)) {
- return null;
- }
- var localX:Number = localPoint.x;
- var localY:Number = localPoint.y;
- var child: DisplayObject = real;
- getTransformationMatrix(child, scratchMatrix);
- MatrixUtil.transformCoords(scratchMatrix, localX, localY, scratchPoint);
- var target: DisplayObject = real.hitTest(scratchPoint, forTouch);
- return target;
- }
- /** @inheritDoc */
- public override function render(support:RenderSupport, parentAlpha:Number):void {
- if(!real.hasVisibleArea) return;
- var alpha:Number = parentAlpha * this.alpha;
- var oldBlendMode:String = support.blendMode;
- support.pushMatrix();
- support.transformMatrix(real);
- support.blendMode = real.blendMode;
- var filter:FragmentFilter = real.filter;
- if(filter) {
- filter.render(real, support, alpha);
- } else {
- real.render(support, alpha);
- }
- support.blendMode = oldBlendMode;
- support.popMatrix();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement