modules/assets: make animation support mask Fix #4
This commit is contained in:
parent
2e608f7fac
commit
ccf1621123
3 changed files with 13 additions and 0 deletions
|
@ -65,6 +65,7 @@ function TestScene:draw()
|
||||||
love.graphics.setColor(0, 1, 0, 1)
|
love.graphics.setColor(0, 1, 0, 1)
|
||||||
self.assets.images["debris"]:drawMask(16, 32)
|
self.assets.images["debris"]:drawMask(16, 32)
|
||||||
self.assets.tileset["weapon"]:drawTileMask(3, 32, 32)
|
self.assets.tileset["weapon"]:drawTileMask(3, 32, 32)
|
||||||
|
self.assets.sprites["poof"]:drawAnimationMask(64, 32)
|
||||||
|
|
||||||
utils.graphics.resetColor()
|
utils.graphics.resetColor()
|
||||||
end
|
end
|
||||||
|
|
|
@ -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)
|
self.sprite:drawFrame(self.frame, x, y, r, sx, sy, ox, oy, kx, ky)
|
||||||
end
|
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)
|
function Animator:changeAnimation(name, restart)
|
||||||
-- Force restart if animation name is different
|
-- Force restart if animation name is different
|
||||||
if (self.currentAnimation ~= name) then
|
if (self.currentAnimation ~= name) then
|
||||||
|
|
|
@ -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)
|
self.animator:draw(x, y, r, sx, sy, ox, oy, kx, ky)
|
||||||
end
|
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)
|
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)
|
self.tileset:drawTile(frame, x, y, r, sx, sy, ox, oy, kx, ky)
|
||||||
end
|
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)
|
function Sprite:drawPart(x, y, w, h, r, sx, sy, ox, oy, kx, ky)
|
||||||
local w = math.floor(w)
|
local w = math.floor(w)
|
||||||
local h = math.floor(h)
|
local h = math.floor(h)
|
||||||
|
|
Loading…
Reference in a new issue