2021-04-21 21:14:45 +02:00
|
|
|
local cwd = (...):gsub('%.gfx$', '') .. "."
|
|
|
|
local Parent = require(cwd .. "parent")
|
|
|
|
local GFX = Parent:extend()
|
|
|
|
|
|
|
|
function GFX:new(world, x, y, spritename)
|
|
|
|
local width, height = world.scene.assets.sprites[spritename]:getDimensions()
|
|
|
|
|
|
|
|
GFX.super.new(self, world, "gfx", x - (width/2), y - (height/2), width, height)
|
2021-05-06 16:08:08 +02:00
|
|
|
self:setSprite(spritename, true)
|
2021-04-21 21:14:45 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function GFX:animationEnded(animation)
|
|
|
|
core.debug:print("gfx2D", 'Current animation "' .. animation .. '" have ended, destroying gfx')
|
|
|
|
self:destroy()
|
|
|
|
end
|
|
|
|
|
|
|
|
function GFX:draw()
|
|
|
|
local x, y = math.floor(self.x), math.floor(self.y)
|
|
|
|
self:drawSprite(x, y)
|
|
|
|
end
|
|
|
|
|
|
|
|
return GFX
|