sonic-radiance/sonic-radiance.love/scenes/overworld/actors/player/charset.lua

43 lines
1.2 KiB
Lua

local PlayerCharset = Object:extend()
local ACTIONS_LARGEANIM = {"jump"}
local ACTIONS_ISFAST = {"jump", "fly", "run", "jumpdash"}
local ACTIONS_ALWAYSWALK = {"fly"}
function PlayerCharset:initPlayerCharset()
self.scissorSprite = true
self:updateCurrentCharset()
end
function PlayerCharset:updateCurrentCharset()
self:setCharset(self:getCharset(), self.active.data.charId)
self.isFast = self:getIsFast()
self.largeAnim = self:getLargeAnim()
self.alwaysWalk = self:getAlwaysWalk()
end
function PlayerCharset:getCharset()
local charset = self.active.data.charset
if (self.currentAction == "jump" or self.currentAction == "jumpdash") then
charset = charset .. "-jump"
elseif (self.currentAction == "fly") then
charset = charset .. "-flight"
elseif (self.currentAction == "punch") then
charset = charset .. "-jump"
end
return charset
end
function PlayerCharset:getLargeAnim()
return utils.table.contain(ACTIONS_LARGEANIM, self.currentAction)
end
function PlayerCharset:getIsFast()
return utils.table.contain(ACTIONS_ISFAST, self.currentAction)
end
function PlayerCharset:getAlwaysWalk()
return utils.table.contain(ACTIONS_ALWAYSWALK, self.currentAction)
end
return PlayerCharset