Skip to main content

Player

Methods​

animate​

Sets the spritesheet to the new key value.

player:animate(lastKey: string) -> none

stop​

Stops the player movement.

player:stop() -> none

canAttack​

Returns true if the player can attack.

player:canAttack() -> boolean

calculatePosition​

Calculates the next x, y position of the player.

player:calculatePosition(lastKey: string) -> array

canMove​

Returns true if the player can move.

player:canMove() -> boolean

attack​

Plays attack animation and runs hit detection on the passed enemies.

player:attack(enemies: array) -> none

attackFinished​

Resets player after an attack.

player:attackFinished() -> none

Properties​

playerSprite​

  • Type: sprite instance

Sprite to represent the player.

attackSprite​

  • Type: sprite instance

Sprite to represent player attacks.

enemyZones​

  • Type: zone instance

The boundaries used for hit detection on attacks.

boundaryZones​

  • Type: zone instance

The boundaries used for map collisions.