Constructor
new GameGif(gifName, attrs)
Constructor of Gif drawable
Parameters:
Name | Type | Description |
---|---|---|
gifName |
string | Name of the gif (without "_sheet.png") |
attrs |
Object | Attribute object |
Properties:
Name | Type | Description |
---|---|---|
img |
Image | Image to be drawn. File generated from python script (NAME_sheet.png) |
imgData |
Object | Data from resources/GIFNAME_data.json |
stagger |
number | Number of frames skipped while redrawing the context |
currentFrame |
number | Current frame of image |
- Source:
Extends
Methods
copy(newName) → {GameGif}
Returns copy of current instance.
Parameters:
Name | Type | Description |
---|---|---|
newName |
string | Name of the newly created instance. Names have to be unique. |
- Overrides:
- Source:
Returns:
New instance of GameGif with the same attributes.
- Type
- GameGif
draw(ctx)
Transforms input context and calls draw function of passed drawable.
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | Rendering context. |
- Overrides:
- Source:
drawFunction(ctx)
Called when drawing
Parameters:
Name | Type | Description |
---|---|---|
ctx |
CanvasRenderingContext2D | Rendering context on which the method draws |
- Overrides:
- Source:
getAttrs() → {Object}
Returns object of attributes of current instance.
- Overrides:
- Source:
Returns:
Attribute object.
- Type
- Object
isInside(mouse, tempContext) → {boolean}
Returns true when mouse is inside drawable.
Parameters:
Name | Type | Description |
---|---|---|
mouse |
Point | Mouse position on canvas. |
tempContext |
CanvasRenderingContext2D | Hidden rendering context to check pixel state. |
- Overrides:
- Source:
Returns:
True when mouse is inside drawable, false otherwise.
- Type
- boolean
setImg(gifName)
Setter for displayed gif. Requires presence of both name_sheet.png and name_data.json in resources/ directory
Parameters:
Name | Type | Description |
---|---|---|
gifName |
string | Name of gif without extension |
- Source:
updateAnimation()
Updates counter of skipped frames or updates the current image
- Source: