WIP: new-cbs #117
7 changed files with 80 additions and 11 deletions
|
@ -1,17 +1,23 @@
|
|||
local PlayerControls = Object:extend()
|
||||
|
||||
function PlayerControls:applyInputs()
|
||||
if (self.world.autorun == true) then
|
||||
self:applyAutorunInput()
|
||||
else
|
||||
self:applyMoveInput()
|
||||
end
|
||||
self:applyMoveInput()
|
||||
self:applyJumpInput()
|
||||
self:applyActionsInputs()
|
||||
self:applySwitchInputs()
|
||||
end
|
||||
|
||||
function PlayerControls:applyMoveInput()
|
||||
if (self:getStateVar("canMove", false)) then
|
||||
if (self.world.autorun == true) then
|
||||
self:applyAutorunInput()
|
||||
else
|
||||
self:applyFreemoveInput()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PlayerControls:applyFreemoveInput()
|
||||
local angle, strenght = self:dpadToAngle()
|
||||
if (strenght ~= 0) then
|
||||
self:goTowardDir(angle, strenght)
|
||||
|
@ -62,8 +68,9 @@ end
|
|||
|
||||
|
||||
function PlayerControls:applyActionsInputs()
|
||||
if self.keys["B"].isPressed and (self.onGround) then
|
||||
-- Nothing for the moment
|
||||
if self.keys["B"].isPressed then
|
||||
--self:setState("hit1")
|
||||
self:playStateFunc("bAction")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -38,10 +38,6 @@ function Player:timerResponse(response)
|
|||
end
|
||||
end
|
||||
|
||||
function Player:animationEnded(name)
|
||||
|
||||
end
|
||||
|
||||
function Player:getViewCenter()
|
||||
local x, y = Player.super.getViewCenter(self)
|
||||
return x, y-16
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
local hit1state = {}
|
||||
|
||||
hit1state.canSwitch = false
|
||||
hit1state.canJump = false
|
||||
hit1state.defaultAnim = false
|
||||
hit1state.canMove = false
|
||||
|
||||
function hit1state:start()
|
||||
self.sprite:changeAnimation("hit1", true)
|
||||
end
|
||||
|
||||
function hit1state:bAction()
|
||||
self:setState("hit2")
|
||||
end
|
||||
|
||||
function hit1state:animationEnded()
|
||||
self:setState("idle")
|
||||
end
|
||||
|
||||
return hit1state
|
|
@ -0,0 +1,20 @@
|
|||
local hit1state = {}
|
||||
|
||||
hit1state.canSwitch = false
|
||||
hit1state.canJump = false
|
||||
hit1state.defaultAnim = false
|
||||
hit1state.canMove = false
|
||||
|
||||
function hit1state:start()
|
||||
self.sprite:changeAnimation("hit2", true)
|
||||
end
|
||||
|
||||
function hit1state:bAction()
|
||||
self:setState("hit3")
|
||||
end
|
||||
|
||||
function hit1state:animationEnded()
|
||||
self:setState("idle")
|
||||
end
|
||||
|
||||
return hit1state
|
|
@ -0,0 +1,16 @@
|
|||
local hit1state = {}
|
||||
|
||||
hit1state.canSwitch = false
|
||||
hit1state.canJump = false
|
||||
hit1state.defaultAnim = false
|
||||
hit1state.canMove = false
|
||||
|
||||
function hit1state:start()
|
||||
self.sprite:changeAnimation("hit3", true)
|
||||
end
|
||||
|
||||
function hit1state:animationEnded()
|
||||
self:setState("idle")
|
||||
end
|
||||
|
||||
return hit1state
|
|
@ -3,5 +3,12 @@ local idleState = {}
|
|||
idleState.canSwitch = true
|
||||
idleState.canJump = true
|
||||
idleState.defaultAnim = true
|
||||
idleState.canMove = true
|
||||
|
||||
function idleState:bAction()
|
||||
if (self.onGround) then
|
||||
self:setState("hit1")
|
||||
end
|
||||
end
|
||||
|
||||
return idleState
|
|
@ -1,3 +1,6 @@
|
|||
return {
|
||||
"idle",
|
||||
"hit1",
|
||||
"hit2",
|
||||
"hit3",
|
||||
}
|
Loading…
Reference in a new issue