Class Player
Defined in: Player.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Player()
A class to represent the player on the screen
|
Field Attributes | Field Name and Description |
---|---|
True if the player is moving down, false otherwise
|
|
True if the player is moving left, false otherwise
|
|
True if the player is moving right, false otherwise
|
|
The speed that the player moves at
|
|
True if the player is moving up, false otherwise
|
Method Attributes | Method Name and Description |
---|---|
keyDown(event)
Called when a key is pressed
|
|
keyUp(event)
Called when a key is pressed
|
|
Initialises this object
|
|
update(dt, context, xScroll, yScroll)
Updates the object
|
Field Detail
{Boolean}
down
True if the player is moving down, false otherwise
{Boolean}
left
True if the player is moving left, false otherwise
{Boolean}
right
True if the player is moving right, false otherwise
{Number}
speed
The speed that the player moves at
{Boolean}
up
True if the player is moving up, false otherwise
Method Detail
keyDown(event)
Called when a key is pressed
- Parameters:
- event
- Event Object
keyUp(event)
Called when a key is pressed
- Parameters:
- event
- Event Object
startupPlayer()
Initialises this object
update(dt, context, xScroll, yScroll)
Updates the object
- Parameters:
- {Number} dt
- The time since the last frame in seconds
- {CanvasRenderingContext2D} context
- The drawing context
- {Number} xScroll
- The global scrolling value of the x axis
- {Number} yScroll
- The global scrolling value of the y axis