sonic-radiance/sonic-radiance.love/scenes/battlesystem/actors/gfx.lua

49 lines
1.3 KiB
Lua
Raw Normal View History

local Parent = require("scenes.battlesystem.actors.movable")
local GFX = Parent:extend()
local GFX_DIRECTORY = "assets/sprites/gfx/"
function GFX:new(world, x, y, z, spritename, creator, blockProcess, tag)
GFX.super.new(self, world, x, y, z)
self:loadAnimation(spritename)
self.creator = creator
self.blockProcess = blockProcess or false
self.tag = tag or ""
if (not utils.string.isEmpty(self.tag)) then
self:setIndexName(self.tag)
end
self.direction = 1
end
function GFX:loadAnimation(spritename)
if self.world.assets.sprites[spritename] == nil then
self.world.assets:addSprite(spritename, GFX_DIRECTORY .. spritename)
end
local width, height = self.world.assets.sprites[spritename]:getDimensions()
self:setSprite(spritename, width/2, height, true)
self:cloneSprite()
end
function GFX:animationEnded(animation)
core.debug:print("gfx", 'Current animation "' .. animation .. '" have ended, destroying gfx')
if (self.blockProcess) and (self.creator ~= nil) and (self.creator.getSignal ~= nil) then
self.creator:getSignal("gfxEnded")
end
if ((self.creator ~= nil) and (self.creator.choregraphy ~= nil) and (not utils.string.isEmpty(self.tag))) then
self.creator.choregraphy:finishTagAction(self.tag)
end
self:destroy()
end
function GFX:draw()
self:drawSprite(0, -self.z)
end
function GFX:drawShadow()
end
return GFX