Created
April 19, 2012 17:02
-
-
Save PrimaryFeather/2422317 to your computer and use it in GitHub Desktop.
Revisions
-
PrimaryFeather revised this gist
Nov 20, 2012 . 1 changed file with 6 additions and 37 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,12 +23,12 @@ package starling.extensions if (context == null) throw new MissingContextError(); support.finishQuadBatch(); support.scissorRectangle = mClipRect; super.render(support, alpha); support.finishQuadBatch(); support.scissorRectangle = null; } } @@ -40,52 +40,21 @@ package starling.extensions // on a touch test, invisible or untouchable objects cause the test to fail if (forTouch && (!visible || !touchable)) return null; if (mClipRect.containsPoint(localToGlobal(localPoint))) return super.hitTest(localPoint, forTouch); else return null; } public function get clipRect():Rectangle { return mClipRect; } public function set clipRect(value:Rectangle):void { if (value) { if (mClipRect == null) mClipRect = value.clone(); else mClipRect.setTo(value.x, value.y, value.width, value.height); } else mClipRect = null; } } } -
PrimaryFeather revised this gist
Aug 7, 2012 . 1 changed file with 12 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -51,30 +51,29 @@ package starling.extensions public function get clipRect():Rectangle { if (mClipRect) { var scaleX:Number = contentScaleX; var scaleY:Number = contentScaleY; return new Rectangle(mClipRect.x / scaleX, mClipRect.y / scaleY, mClipRect.width / scaleX, mClipRect.height / scaleY); } else return null; } public function set clipRect(value:Rectangle):void { if (value) { var scaleX:Number = contentScaleX; var scaleY:Number = contentScaleY; if (mClipRect == null) mClipRect = new Rectangle(); mClipRect.setTo(scaleX * value.x, scaleY * value.y, scaleX * value.width, scaleY * value.height); } else mClipRect = null; } private function get contentScaleX():Number -
PrimaryFeather revised this gist
Aug 7, 2012 . 1 changed file with 21 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,23 +49,32 @@ package starling.extensions return null; } public function get clipRect():Rectangle { if (mClipRect == null) return null; var scaleX:Number = contentScaleX; var scaleY:Number = contentScaleY; return new Rectangle(mClipRect.x / scaleX, mClipRect.y / scaleY, mClipRect.width / scaleX, mClipRect.height / scaleY); } public function set clipRect(value:Rectangle):void { if (value == null) { mClipRect = null; } else { var scaleX:Number = contentScaleX; var scaleY:Number = contentScaleY; if (mClipRect == null) mClipRect = new Rectangle(); mClipRect.setTo(scaleX * value.x, scaleY * value.y, scaleX * value.width, scaleY * value.height); } } private function get contentScaleX():Number -
Daniel Sperl revised this gist
Jul 17, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,6 @@ package starling.extensions import starling.core.Starling; import starling.display.DisplayObject; import starling.display.Sprite; import starling.errors.MissingContextError; public class ClippedSprite extends Sprite @@ -41,6 +40,7 @@ package starling.extensions // on a touch test, invisible or untouchable objects cause the test to fail if (forTouch && (!visible || !touchable)) return null; var scale:Number = Starling.current.contentScaleFactor; var globalPoint:Point = localToGlobal(localPoint); if (mClipRect.contains(globalPoint.x * contentScaleX, globalPoint.y * contentScaleY)) -
Daniel Sperl revised this gist
Jul 17, 2012 . 1 changed file with 17 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,36 +41,43 @@ package starling.extensions // on a touch test, invisible or untouchable objects cause the test to fail if (forTouch && (!visible || !touchable)) return null; var globalPoint:Point = localToGlobal(localPoint); if (mClipRect.contains(globalPoint.x * contentScaleX, globalPoint.y * contentScaleY)) return super.hitTest(localPoint, forTouch); else return null; } public function get clipRect():Rectangle { var scaleX:Number = contentScaleX; var scaleY:Number = contentScaleY; return new Rectangle(mClipRect.x / scaleX, mClipRect.y / scaleY, mClipRect.width / scaleX, mClipRect.height / scaleY); } public function set clipRect(value:Rectangle):void { var scaleX:Number = contentScaleX; var scaleY:Number = contentScaleY; if (mClipRect == null) mClipRect = new Rectangle(); mClipRect.setTo(scaleX * value.x, scaleY * value.y, scaleX * value.width, scaleY * value.height); } private function get contentScaleX():Number { var currentStarling:Starling = Starling.current; return currentStarling.viewPort.width / currentStarling.stage.stageWidth; } private function get contentScaleY():Number { var currentStarling:Starling = Starling.current; return currentStarling.viewPort.height / currentStarling.stage.stageHeight; } } } -
Daniel Sperl revised this gist
Jul 16, 2012 . 1 changed file with 18 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,12 +8,13 @@ package starling.extensions import starling.core.Starling; import starling.display.DisplayObject; import starling.display.Sprite; import starling.display.Stage; import starling.errors.MissingContextError; public class ClippedSprite extends Sprite { private var mClipRect:Rectangle; public override function render(support:RenderSupport, alpha:Number):void { if (mClipRect == null) super.render(support, alpha); @@ -24,14 +25,14 @@ package starling.extensions support.finishQuadBatch(); context.setScissorRectangle(mClipRect); super.render(support, alpha); support.finishQuadBatch(); context.setScissorRectangle(null); } } public override function hitTest(localPoint:Point, forTouch:Boolean=false):DisplayObject { // without a clip rect, the sprite should behave just like before @@ -51,17 +52,25 @@ package starling.extensions public function get clipRect():Rectangle { var viewPort:Rectangle = Starling.current.viewPort; var stage:Stage = Starling.current.stage; var scaleX:Number = viewPort.width / stage.stageWidth; var scaleY:Number = viewPort.height / stage.stageHeight; return new Rectangle(mClipRect.x / scaleX, mClipRect.y / scaleY, mClipRect.width / scaleX, mClipRect.height / scaleY); } public function set clipRect(value:Rectangle):void { var viewPort:Rectangle = Starling.current.viewPort; var stage:Stage = Starling.current.stage; var scaleX:Number = viewPort.width / stage.stageWidth; var scaleY:Number = viewPort.height / stage.stageHeight; if (mClipRect == null) mClipRect = new Rectangle(); mClipRect.setTo(scaleX * value.x, scaleY * value.y, scaleX * value.width, scaleY * value.height); } } } -
Daniel Sperl revised this gist
Jul 9, 2012 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,12 @@ package starling.extensions { import flash.display3D.Context3D; import flash.geom.Point; import flash.geom.Rectangle; import starling.core.RenderSupport; import starling.core.Starling; import starling.display.DisplayObject; import starling.display.Sprite; import starling.errors.MissingContextError; -
Daniel Sperl revised this gist
Jun 10, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,12 +32,12 @@ package starling.extensions public override function hitTest(localPoint:Point, forTouch:Boolean=false):DisplayObject { // without a clip rect, the sprite should behave just like before if (mClipRect == null) return super.hitTest(localPoint, forTouch); // on a touch test, invisible or untouchable objects cause the test to fail if (forTouch && (!visible || !touchable)) return null; var scale:Number = Starling.current.contentScaleFactor; var globalPoint:Point = localToGlobal(localPoint); -
Daniel Sperl revised this gist
Jun 10, 2012 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -35,6 +35,9 @@ package starling.extensions // on a touch test, invisible or untouchable objects cause the test to fail if (forTouch && (!visible || !touchable)) return null; // without a clip rect, the sprite should behave just like before if (mClipRect == null) return super.hitTest(localPoint, forTouch); var scale:Number = Starling.current.contentScaleFactor; var globalPoint:Point = localToGlobal(localPoint); -
Daniel Sperl revised this gist
Apr 21, 2012 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,6 +29,20 @@ package starling.extensions context.setScissorRectangle(null); } } public override function hitTest(localPoint:Point, forTouch:Boolean=false):DisplayObject { // on a touch test, invisible or untouchable objects cause the test to fail if (forTouch && (!visible || !touchable)) return null; var scale:Number = Starling.current.contentScaleFactor; var globalPoint:Point = localToGlobal(localPoint); if (mClipRect.contains(globalPoint.x * scale, globalPoint.y * scale)) return super.hitTest(localPoint, forTouch); else return null; } public function get clipRect():Rectangle { -
Daniel Sperl revised this gist
Apr 20, 2012 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -40,8 +40,9 @@ package starling.extensions public function set clipRect(value:Rectangle):void { var scale:Number = Starling.current.contentScaleFactor; if (mClipRect == null) mClipRect = new Rectangle(); mClipRect.x = scale * value.x; mClipRect.y = scale * value.y; mClipRect.width = scale * value.width; mClipRect.height = scale * value.height; } } } -
Daniel Sperl revised this gist
Apr 19, 2012 . 1 changed file with 9 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,18 +10,18 @@ package starling.extensions public class ClippedSprite extends Sprite { private var mClipRect:Rectangle; public override function render(support:RenderSupport, alpha:Number):void { if (mClipRect == null) super.render(support, alpha); else { var context:Context3D = Starling.context; if (context == null) throw new MissingContextError(); support.finishQuadBatch(); context.setScissorRectangle(mClipRect); super.render(support, alpha); @@ -30,16 +30,18 @@ package starling.extensions } } public function get clipRect():Rectangle { var scale:Number = Starling.current.contentScaleFactor; return new Rectangle(mClipRect.x / scale, mClipRect.y / scale, mClipRect.width / scale, mClipRect.height / scale); } public function set clipRect(value:Rectangle):void { var scale:Number = Starling.current.contentScaleFactor; mClipRect = new Rectangle(value.x * scale, value.y * scale, value.width * scale, value.height * scale); } } } -
Daniel Sperl renamed this gist
Apr 19, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,7 +8,7 @@ package starling.extensions import starling.display.Sprite; import starling.errors.MissingContextError; public class ClippedSprite extends Sprite { private var mMask:Rectangle; -
Daniel Sperl created this gist
Apr 19, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ package starling.extensions { import flash.display3D.Context3D; import flash.geom.Rectangle; import starling.core.RenderSupport; import starling.core.Starling; import starling.display.Sprite; import starling.errors.MissingContextError; public class MaskedSprite extends Sprite { private var mMask:Rectangle; public override function render(support:RenderSupport, alpha:Number):void { if (mMask == null) super.render(support, alpha); else { var context:Context3D = Starling.context; if (context == null) throw new MissingContextError(); support.finishQuadBatch(); context.setScissorRectangle(mMask); super.render(support, alpha); support.finishQuadBatch(); context.setScissorRectangle(null); } } public function get mask():Rectangle { var scale:Number = Starling.current.contentScaleFactor; return new Rectangle(mMask.x/scale, mMask.y/scale, mMask.width/scale, mMask.height/scale); } public function set mask(value:Rectangle):void { var scale:Number = Starling.current.contentScaleFactor; mMask = new Rectangle(value.x*scale, value.y*scale, value.width*scale, value.height*scale); } } }