Skip to content

Commit ed756d1

Browse files
committed
Fixed Get Tiles Within Shape function
1 parent 0074fcd commit ed756d1

1 file changed

Lines changed: 15 additions & 25 deletions

File tree

src/tilemaps/components/GetTilesWithinShape.js

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,21 @@ var GetTilesWithinShape = function (shape, filteringOptions, camera, layer)
4343
// intersectTest is a function with parameters: shape, rect
4444
var intersectTest = NOOP;
4545

46-
switch (typeof(shape))
46+
if (shape instanceof Geom.Circle)
4747
{
48-
case Geom.Circle:
49-
{
50-
intersectTest = Intersects.CircleToRectangle;
51-
break;
52-
}
53-
54-
case Geom.Rectangle:
55-
{
56-
intersectTest = Intersects.RectangleToRectangle;
57-
break;
58-
}
59-
60-
case Geom.Triangle:
61-
{
62-
intersectTest = TriangleToRectangle;
63-
break;
64-
}
65-
66-
case Geom.Line:
67-
{
68-
intersectTest = Intersects.LineToRectangle;
69-
break;
70-
}
48+
intersectTest = Intersects.CircleToRectangle;
49+
}
50+
else if (shape instanceof Geom.Rectangle)
51+
{
52+
intersectTest = Intersects.RectangleToRectangle;
53+
}
54+
else if (shape instanceof Geom.Triangle)
55+
{
56+
intersectTest = TriangleToRectangle;
57+
}
58+
else if (shape instanceof Geom.Line)
59+
{
60+
intersectTest = Intersects.LineToRectangle;
7161
}
7262

7363
// Top left corner of the shapes's bounding box, rounded down to include partial tiles
@@ -105,7 +95,7 @@ var GetTilesWithinShape = function (shape, filteringOptions, camera, layer)
10595
{
10696
var tile = tiles[i];
10797

108-
layer.tilemapLayer.tileToWorldXY(tile.x, tile.y, point, camera, layer);
98+
layer.tilemapLayer.tileToWorldXY(tile.x, tile.y, point, camera);
10999

110100
tileRect.x = point.x;
111101
tileRect.y = point.y;

0 commit comments

Comments
 (0)