feat(charset): add mirroring and 'large anim'
This commit is contained in:
parent
2ede81dc8d
commit
6569cb0dd7
1 changed files with 26 additions and 8 deletions
|
@ -79,25 +79,43 @@ end
|
|||
|
||||
-- DRAW FUNCTIONS
|
||||
-- Draw the charset in various situations
|
||||
function Charset:draw(charsetName, charID, direction, frame, x, y)
|
||||
function Charset:draw(charsetName, charID, direction, frame, x, y, isMirrored)
|
||||
local drawable = self:getTexture(charsetName)
|
||||
local quad = self:getQuad(frame, charID, direction)
|
||||
love.graphics.draw(drawable, quad, math.floor(x), math.floor(y), 0, 1, 1, 11, 32)
|
||||
local sx = 1
|
||||
if (isMirrored == false) then
|
||||
sx = -1
|
||||
end
|
||||
love.graphics.draw(drawable, quad, math.floor(x) + 8, math.floor(y), 0, sx, 1, 19, 32)
|
||||
end
|
||||
|
||||
function Charset:drawMoving(charsetName, charID, direction, x, y, isFast)
|
||||
function Charset:drawMoving(charsetName, charID, direction, x, y, isFast, isMirrored)
|
||||
local frame = self:getCurrentFrame(isFast)
|
||||
self:draw(charsetName, charID, direction, frame, x, y)
|
||||
self:draw(charsetName, charID, direction, frame, x, y, isMirrored)
|
||||
end
|
||||
|
||||
function Charset:drawStanding(charsetName, charID, direction, x, y)
|
||||
self:draw(charsetName, charID, direction, FRAME_STANDING, x, y)
|
||||
function Charset:drawStanding(charsetName, charID, direction, x, y, isMirrored)
|
||||
self:draw(charsetName, charID, direction, FRAME_STANDING, x, y, isMirrored)
|
||||
end
|
||||
|
||||
function Charset:drawTurning(charsetName, charID, x, y, isFast, frame)
|
||||
function Charset:drawLargeAnim(charsetName, charID, direction, x, y, isFast)
|
||||
local frame = FRAME_STANDING
|
||||
local isMirrored = false
|
||||
for i, dir in ipairs(directionList) do
|
||||
if (dir == direction) then
|
||||
frame = animation[i]
|
||||
end
|
||||
end
|
||||
if (direction == "right") then
|
||||
isMirrored = true
|
||||
end
|
||||
self:drawTurning(charsetName, charID, x, y, isFast, frame, isMirrored)
|
||||
end
|
||||
|
||||
function Charset:drawTurning(charsetName, charID, x, y, isFast, frame, isMirrored)
|
||||
local frame = frame or FRAME_STANDING
|
||||
local dir = self:getCurrentFrame(isFast)
|
||||
return self:draw(charsetName, charID, directionList[dir], frame, x, y)
|
||||
return self:draw(charsetName, charID, directionList[dir], frame, x, y, isMirrored)
|
||||
end
|
||||
|
||||
return Charset
|
||||
|
|
Loading…
Reference in a new issue