Constructor
new GameDrawable(attrs)
Parameters:
Name | Type | Description |
---|---|---|
attrs |
Object | Attributes of new Drawable. |
Properties:
Name | Type | Description |
---|---|---|
name |
string | Name of the drawable, used for searching for it within element. |
level |
number | Depth of drawable within element. Higher number will be on top. |
dx |
number | Deviation on X axis in pixels from center of parent Element. |
dy |
number | Deviation on Y axis in pixels from center of parent Element. |
width |
number | Width of the drawable in pixels. Used for rectangles and images. |
height |
number | Height of the drawable in pixels. Used for rectangles and images. |
rotation |
number | Rotation of the drawable. Measured in radians. |
visible |
boolean | Visibility of drawable. Skips drawing on false. |
hScale |
number | Scale of drawable on horizontal axis. 1 is default, -1 is mirrored. |
vScale |
number | Scale of drawable on vertical axis. 1 is default, -1 is mirrored. |
- Source:
Methods
copy(newName) → {GameDrawable}
Returns copy of current instance.
Parameters:
Name | Type | Description |
---|---|---|
newName |
string | Name of the newly created instance. Names have to be unique. |
- Source:
Returns:
New instance of Drawable with the same attributes.
- Type
- GameDrawable
draw(ctx)
Transforms input context and calls draw function of passed drawable.
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | Rendering context. |
- Source:
drawFunction(ctx)
Draws the object on the supplied context
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | Rendering context on which the method draws |
- Source:
getAttrs() → {Object}
Returns object of attributes of current instance.
- Source:
Returns:
Attribute object.
- Type
- Object