refactor(levels): use the gfx2D actor directly instead of old gfx entity

This commit is contained in:
Kazhnuz 2019-06-16 18:24:49 +02:00
parent 0b9d34abe2
commit 91ce8ba9c0
2 changed files with 2 additions and 31 deletions

View File

@ -1,30 +0,0 @@
local Entity = require "scenes.levels.entities.parent"
local Animator = require "core.modules.assets.animator"
local GFX = Entity:extend()
function GFX:new(world, x, y, spritename, animID)
local width, height
self.name = spritename
self.animID = animID
width = 16
height = 16
GFX.super.new(self, world, "gfx", x - (width/2), y - (height/2), width, height)
self.animation = self.scene.assets.sprites[spritename]:clone()
self.duration = self.animation:getAnimationDuration()
self.timer = 0
end
function GFX:update(dt)
self.timer = self.timer + dt
self.animation:update(dt)
if (self.timer >= self.duration) then
self:destroy()
end
end
function GFX:draw(dt)
self.animation:draw(self.x, self.y)
end
return GFX

View File

@ -8,13 +8,14 @@ Obj.Coin = require "scenes.levels.entities.loot.coin"
Obj.Coin5 = require "scenes.levels.entities.loot.coin5"
Obj.Coin10 = require "scenes.levels.entities.loot.coin10"
Obj.Weapon = require "scenes.levels.entities.weapon"
Obj.GFX = require "scenes.levels.entities.gfx.gfx"
Obj.Numbers = require "scenes.levels.entities.gfx.numbers"
Obj.Debris = require "scenes.levels.entities.debris"
Obj.Player = require "scenes.levels.entities.player"
Obj.Ennemy = require "scenes.levels.entities.ennemies.parent"
Obj.GFX = require "core.modules.world.actors.gfx2D"
Obj.index = {}
Obj.index["coin"] = Obj.Coin