Constructor
new Polygon(x, y, points)
| Name | Type | Description |
|---|---|---|
x | number | The x position |
y | number | The y position |
points | Array.<gameify.Vector2d> | The points of the polygon, relative to the position of the polygon |
- Source
Extends
Members
copy
Create a copy of the shape
- Overrides
- Source
fillColor :String
The fill color when this shape is drawn
- String
- Overrides
- Source
points :Array.<gameify.Vector2d>
The points of the polygon, relative to the position of the polygon
- Array.<gameify.Vector2d>
- Source
position :gameify.Vector2d
The position of the shape, often locked to the position of a sprite that it represents
- Overrides
- Source
(readonly) segments :Array.<LineSegment>
The polygon, as an array of line segments, relative to the position of the polygon
- Array.<LineSegment>
- Source
strokeColor :String
The stroke color when this shape is drawn
- String
- Overrides
- Source
(readonly) type :String
A string represeting the type of shape, eg "Circle"
- String
- Overrides
- Source
Methods
collidesWith(obj, recursionopt) → {Boolean}
Check if this shape collides with another shape
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
obj | shapes. | The object to check for collision | ||
recursion | Boolean | <optional> | false | If this is a recursive call |
- Overrides
- Source
- Type:
- Boolean
contains(point) → {Boolean}
Check if a point (Vector2d) is inside this shape
| Name | Type | Description |
|---|---|---|
point | gameify. | The point to check |
- Overrides
- Source
- Type:
- Boolean
draw(context)
Draw a hitbox for debugging
| Name | Type | Description |
|---|---|---|
context | CanvasRenderingContext2D | The rendering context to draw to |
- Overrides
- Source
fromJSON(data) → {gameify.Tileset}
Creates a object from JSON data
| Name | Type | Description |
|---|---|---|
data | Object | | Serialized object data (from object.toJSON) |
- Overrides
- Source
- Type:
- gameify.
Tileset
rotated(angle, pointopt) → {gameify.shapes.Polygon}
Create a copy of this shape, rotated around a point, in radians (counterclockwise)
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
angle | Number | The angle to rotate by, in radians | ||
point | gameify. | <optional> | <0, 0> | The point to rotate around |
- Overrides
- Source
- Type:
- gameify.
shapes. Polygon
scaled(scale) → {gameify.shapes.Polygon}
Create a copy of this shape, scaled by a factor
| Name | Type | Description |
|---|---|---|
scale | Number | The scale factor |
- Overrides
- Source
- Type:
- gameify.
shapes. Polygon
toJSON()
Convert the object to JSON
- Overrides
- Source