modules/assets: make animation support mask

Fix #1
This commit is contained in:
Kazhnuz 2019-03-18 17:26:01 +01:00
parent 2e608f7fac
commit b0beb74671
3 changed files with 13 additions and 0 deletions

View file

@ -65,6 +65,7 @@ function TestScene:draw()
love.graphics.setColor(0, 1, 0, 1)
self.assets.images["debris"]:drawMask(16, 32)
self.assets.tileset["weapon"]:drawTileMask(3, 32, 32)
self.assets.sprites["poof"]:drawAnimationMask(64, 32)
utils.graphics.resetColor()
end

View file

@ -77,6 +77,10 @@ function Animator:draw(x, y, r, sx, sy, ox, oy, kx, ky)
self.sprite:drawFrame(self.frame, x, y, r, sx, sy, ox, oy, kx, ky)
end
function Animator:drawMask(x, y, r, sx, sy, ox, oy, kx, ky)
self.sprite:drawFrameMask(self.frame, x, y, r, sx, sy, ox, oy, kx, ky)
end
function Animator:changeAnimation(name, restart)
-- Force restart if animation name is different
if (self.currentAnimation ~= name) then

View file

@ -68,10 +68,18 @@ function Sprite:drawAnimation(x, y, r, sx, sy, ox, oy, kx, ky)
self.animator:draw(x, y, r, sx, sy, ox, oy, kx, ky)
end
function Sprite:drawAnimationMask(x, y, r, sx, sy, ox, oy, kx, ky)
self.animator:drawMask(x, y, r, sx, sy, ox, oy, kx, ky)
end
function Sprite:drawFrame(frame, x, y, r, sx, sy, ox, oy, kx, ky)
self.tileset:drawTile(frame, x, y, r, sx, sy, ox, oy, kx, ky)
end
function Sprite:drawFrameMask(frame, x, y, r, sx, sy, ox, oy, kx, ky)
self.tileset:drawTileMask(frame, x, y, r, sx, sy, ox, oy, kx, ky)
end
function Sprite:drawPart(x, y, w, h, r, sx, sy, ox, oy, kx, ky)
local w = math.floor(w)
local h = math.floor(h)