Created
May 8, 2011 09:46
-
-
Save MattMcFarland/961260 to your computer and use it in GitHub Desktop.
polygon
This file contains 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 characters
private static function drawPolygon(map:Map, rect:Rectangle):Vector.<Point> | |
{ | |
var tileWidth:int = map._tileWidth; | |
var tileHeight:int = map._tileHeight; | |
var topRight:Point = tileToPixelCoords(map, new Point(rect.width,0)); | |
var bottomRight:Point = tileToPixelCoords(map, rect.bottomRight); | |
var bottomLeft:Point = tileToPixelCoords(map, new Point(0,rect.bottom)); | |
var polygon:Vector.<Point> = new Vector.<Point>(); | |
polygon.push(qPoint(tileToPixelCoords(map, qPoint(rect.topLeft)))); | |
polygon.push(new Point( topRight.x + tileWidth / 2, | |
topRight.y + tileHeight / 2)); | |
polygon.push(new Point( bottomRight.x, bottomRight.y + tileHeight)); | |
polygon.push(new Point( bottomLeft.x - tileWidth / 2, | |
bottomLeft.y + tileHeight / 2)); | |
return polygon; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment