Constructor
new Shape(type, xopt, yopt)
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
type | string | The shape type | ||
x | number | <optional> | 0 | The x position |
y | number | <optional> | 0 | The y position |
- Source
Members
copy
Create a copy of the shape
- Source
fillColor :String
The fill color when this shape is drawn
- String
- Source
position :gameify.Vector2d
The position of the shape, often locked to the position of a sprite that it represents
- Source
strokeColor :String
The stroke color when this shape is drawn
- String
- Source
(readonly) type :String
A string represeting the type of shape, eg "Circle"
- String
- Source
Methods
(abstract) 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 |
- Source
- Type:
- Boolean
(abstract) contains(point) → {Boolean}
Check if a point (Vector2d) is inside this shape
| Name | Type | Description |
|---|---|---|
point | gameify. | The point to check |
- Source
- Type:
- Boolean
(abstract) draw(context)
Draw a hitbox for debugging
| Name | Type | Description |
|---|---|---|
context | CanvasRenderingContext2D | The rendering context to draw to |
- Source
fromJSON(data) → {gameify.Tileset}
Creates a object from JSON data
| Name | Type | Description |
|---|---|---|
data | Object | | Serialized object data (from object.toJSON) |
- Source
- Type:
- gameify.
Tileset
rotated(angle, pointopt) → {gameify.shapes.Shape}
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 |
- Source
- Type:
- gameify.
shapes. Shape
scaled(scale) → {gameify.shapes.Shape}
Create a copy of this shape, scaled by a factor.
| Name | Type | Description |
|---|---|---|
scale | Number | The scale factor |
- Source
- Type:
- gameify.
shapes. Shape
toJSON()
Convert the object to JSON. Not available on the base Shape, only on inherited classes
- Source