Constructor
new Floor(scene, x, y)
Sets up the default values for the class variables.
Parameters:
| Name | Type | Description |
|---|---|---|
scene |
this is the current Scene object. | |
x |
the starting x pos of the floor. Used in case the floor needs to be repositioned, or positioned starting elsewhere from the left of the screen. | |
y |
the starting y pos of the floor. Used in case the floor needs to be repositioned, or positioned starting elsewhere from the bottom of the screen. |
- Source:
Methods
create()
This method will create the ground and the floor to be displayed on the canvas
- Source:
getHeight() → {number}
This method returns the total height between the floor and the ground
- Source:
Returns:
- the total height between the floor and the ground
- Type
- number
preload()
This function is called before anything is drawn on the canvas.
This allows for asset preloading which prevents anything from drawing without
it first loading the asset.
- Source:
resetG()
Called whenever the game resets. Sets the game state to IDLE
- Source:
startG()
Called whenever the game starts. Sets the game state to RUNNING
- Source:
stopG()
Called whenever the game ends. Sets the game state to PAUSED
- Source:
update()
If the game state is IDLE or RUNNING, it will call velocityToTilePosition. Basically,
It calls it separately in IDLE and RUNNING in case future implementations required different
logic or velocities for each state.
- Source:
updatePosition()
This method will update the ground and floor using given class position variable
- Source:
velocityToTilePosition() → {number}
Based on the given velocity, this returns a new x position that will animate the tileposition.x
at the same speed that the physics animatets the moving pipes.
- Source:
Returns:
- new tile position
- Type
- number