-
Notifications
You must be signed in to change notification settings - Fork 0
Entity: Player
There are different types of Players to be configured in Cotton. You can change the player type by changing the config.playerType
variable in the config.lua
. (More info can be found here: Config Variables)
Player images can be updated just as you would do with an entity.
You would call the following from the Player
script:
self:setImage("images/computer")
This would change the player image to a computer!
If you want an animated sprite, do it like so:
self:setImage("images/floppy", { animated = true, delay = 500, loop = true })
This would change the player image to a moving floppy!
Player specific settings are a little different from updating config settings and have it's own function called setProperty
.
For instance, if you would want to update the transitionMovement
variable of the player.
You would call the following from the Player
script:
self:setProperty("transitionMovement", true)
In Grid mode, you are viewing the player from above, but locked to a grid. It can move freely in all directions but only to locations on the grid. This is also the player style which probably reminds you the most of how things would work in Pulp.
self:setProperty("tileSize", 16)
Controls the size of the tiles in the grid that the player moves in.
self:setProperty("transitionMovement", false)
Controls if the player moves to a tile instantly OR with transition.
self:setProperty("transitionSpeed", 2)
Controls the speed of the transition that a player moves between tiles.
TileSize has to be in table of transitionSpeed. Examples if tileSize = 16:
- 2=OK
- 3=NOT OK
- 4=OK
- 6=NOT OK
- 8=OK
self:setProperty("allowDiagonalMovement", false)
Controls if the player can move on the diagonal axis.
In topdown mode, you are viewing the player from above, but not locked to a grid. It can move freely in all directions.
self:setProperty("playerSpeed", 4)
Controls the max speed of the player.
self:setProperty("playerAcceleration", 1)
Controls the acceleration speed till max speed is reached.
self:setProperty("playerGroundFriction", 0.8)
Controls the friction (speed decrease) of the player after moving.
With Platformer, you are viewing the player from the side. This player type has gravity, AND is not locked to a grid. It can move freely in all directions except up and down. Moving up and down is possible by button and is affected by gravity.
self:setProperty("playerSpeed", 5)
Controls the max speed of the player.
self:setProperty("playerAcceleration", 1)
Controls the acceleration speed till max speed is reached.
self:setProperty("playerGroundFriction", 0.8)
Controls the friction (speed decrease) of the player after moving on ground.
self:setProperty("playerAirFriction", 0.2)
Controls the friction (speed decrease) of the player after moving in the air.
jumpGrace = 0.1,
jumpBuffer = 0.1,
jumpLongPress = 0.12,
jumpVelocity = -15,
gravityUp = 80,
gravityDown = 130,
playerMaxGravity = 40