scenes/levels: use the contained asset system for gfx
This commit is contained in:
parent
343127cd7f
commit
8aba9615ee
|
@ -0,0 +1,16 @@
|
|||
return {
|
||||
metadata = {
|
||||
height = 16,
|
||||
width = 16,
|
||||
defaultAnim = "anim"
|
||||
},
|
||||
animations = {
|
||||
["anim"] = {
|
||||
startAt = 1,
|
||||
endAt = 5,
|
||||
loop = 1,
|
||||
speed = 10,
|
||||
pauseAtEnd = false,
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 580 B |
|
@ -0,0 +1,16 @@
|
|||
return {
|
||||
metadata = {
|
||||
height = 16,
|
||||
width = 16,
|
||||
defaultAnim = "anim"
|
||||
},
|
||||
animations = {
|
||||
["anim"] = {
|
||||
startAt = 1,
|
||||
endAt = 5,
|
||||
loop = 1,
|
||||
speed = 10,
|
||||
pauseAtEnd = false,
|
||||
}
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 520 B |
|
@ -1,4 +1,5 @@
|
|||
local Entity = require "scenes.levels.entities.parent"
|
||||
local Animator = require "core.modules.assets.animator"
|
||||
|
||||
local GFX = Entity:extend()
|
||||
|
||||
|
@ -6,11 +7,11 @@ function GFX:new(level, x, y, spritename, animID)
|
|||
local width, height
|
||||
self.name = spritename
|
||||
self.animID = animID
|
||||
self.animation = assets.sprites[spritename]:cloneAnimation(animID)
|
||||
width = 16--assets.sprites[spritename].width
|
||||
height = 16--assets.sprites[spritename].height
|
||||
GFX.super.new(self, level, "gfx", x - (width/2), y - (height/2), width, height)
|
||||
self.duration = assets.sprites[spritename]:getAnimationDuration(animID)
|
||||
self.animation = self.level.assets.sprites[spritename]:clone()
|
||||
self.duration = self.animation:getAnimationDuration()
|
||||
self.timer = 0
|
||||
--world:add(self, self.x, self.y, self.w, self.h)
|
||||
end
|
||||
|
@ -24,7 +25,7 @@ function GFX:update(dt)
|
|||
end
|
||||
|
||||
function GFX:draw(dt)
|
||||
self.animation:draw(assets.sprites[self.name].image, self.x, self.y)
|
||||
self.animation:draw(self.x, self.y)
|
||||
end
|
||||
|
||||
return GFX
|
||||
|
|
|
@ -82,8 +82,8 @@ function Level:loadSprites()
|
|||
|
||||
self.assets:addTileset("weapon", "assets/sprites/weapon")
|
||||
|
||||
assets:addSprite("sparkle", 16, 16)
|
||||
assets.sprites["sparkle"]:newAnimation('1-5', 1, 0.08, 'pauseAtEnd')
|
||||
self.assets:addSprite("sparkle", "assets/sprites/gfx/sparkle")
|
||||
self.assets:addSprite("poof", "assets/sprites/gfx/poof")
|
||||
|
||||
self:loadCochonSprites("cochon")
|
||||
self:loadCochonSprites("bling-bling")
|
||||
|
@ -94,9 +94,6 @@ function Level:loadSprites()
|
|||
assets:addSprite("debris", 8, 8)
|
||||
assets.sprites["debris"]:newAnimation(1, 1, 0.08)
|
||||
|
||||
assets:addSprite("poof", 16, 16)
|
||||
assets.sprites["poof"]:newAnimation('1-6', 1, 0.08, 'pauseAtEnd')
|
||||
|
||||
assets:addSprite("lifeicons", 16, 16, "pigs/")
|
||||
assets.sprites["lifeicons"]:newAnimation(1, 1, 0.08)
|
||||
assets.sprites["lifeicons"]:newAnimation(2, 1, 0.08)
|
||||
|
|
Loading…
Reference in New Issue