sonic-radiance/sonic-radiance.love/scenes/menus/debugmenus/animation/init.lua

49 lines
1.3 KiB
Lua
Raw Normal View History

local Scene = require "scenes.menus.debugmenus.commons.scene"
2021-07-04 11:43:46 +02:00
local CharAnimViewer = Scene:extend()
local Background = require "game.modules.drawing.parallaxBackground"
local Sprite = require "birb.modules.assets.types.sprites"
function CharAnimViewer:new()
CharAnimViewer.super.new(self)
self.background = Background(self, 5, 1, "city")
self.sprite = nil
end
2021-07-04 11:43:46 +02:00
function CharAnimViewer:initMenu()
2021-07-04 11:43:46 +02:00
for charName, _ in pairs(game.characters.list) do
self.menu:addSubmenu(charName, charName, "main", true)
self.menu:switch(charName)
2021-07-04 11:43:46 +02:00
local sprite = Sprite("datas/gamedata/characters/" .. charName .. "/sprites")
for animName, _ in pairs(sprite.data.animations) do
self.menu:addItem(animName, "left", function()
self:setSpriteAndAnim(charName, animName)
self:hideMenu()
end, "select")
2021-07-04 11:43:46 +02:00
end
end
end
function CharAnimViewer:setSpriteAndAnim(character, animationName)
self.sprite = Sprite("datas/gamedata/characters/" .. character .. "/sprites")
self.sprite:changeAnimation(animationName, true)
end
function CharAnimViewer:update(dt)
CharAnimViewer.super.update(self,dt)
2021-07-04 11:43:46 +02:00
if (self.sprite ~= nil) then
self.sprite:update(dt)
end
end
function CharAnimViewer:draw()
self.background:draw()
if (self.sprite ~= nil) then
2021-08-21 17:05:49 +02:00
self.sprite:draw(424/2, 240/1.5)
2021-07-04 11:43:46 +02:00
end
end
return CharAnimViewer