Polygon object used for hitboxes and click maps. Must pass an Array for each point as an argument where index 0 is the x position and index 1 is the y position.
For example one point of a polygon will look like this: [0,5]
where the x
is 0
and the y
is 5
.
Can pass an array of the points or simply put each point as an argument.
When creating a polygon for an entity, each point should be offset or relative from the entities x
and y
(don't include the absolute values as it will automatically calculate this).
new Crafty.polygon([50,0],[100,100],[0,100]);
new Crafty.polygon([[50,0],[100,100],[0,100]]);
public Boolean .containsPoint(Number x, Number y)
Method is used to determine if a given point is contained by the circle.
var circle = new Crafty.circle(0, 0, 10);
circle.containsPoint(0, 0); //TRUE
circle.containsPoint(50, 50); //FALSE
public void .shift(Number x, Number y)
x
axisy
axisShifts the circle by the specified amount.
var poly = new Crafty.circle(0, 0, 10);
circle.shift(5,5);
//{x: 5, y: 5, radius: 10};