sonic-radiance/sonic-radiance.love/scenes/debug/viewers/animation/init.lua

62 lines
1.7 KiB
Lua
Raw Normal View History

2021-07-04 11:43:46 +02:00
local Scene = require "birb.modules.scenes"
local menu = require "scenes.debug.viewers.animation.menu"
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.assets:batchImport("scenes.debug.commons.assets")
local mainMenu = menu.commons.DebugMenu(self, "MainMenu")
self:setBackground("city")
for charName, _ in pairs(game.characters.list) do
mainMenu:addSubMenu(charName, charName)
local sprite = Sprite("datas/gamedata/characters/" .. charName .. "/sprites")
for animName, _ in pairs(sprite.data.animations) do
menu.AnimationWidget(self, charName, animName)
end
end
menu.commons.SceneWidget(self, "MainMenu", scenes.debug.menu, "Back")
self.menusystem:activate()
self.menusystem:switchMenu("MainMenu")
self.sprite = nil
end
function CharAnimViewer:constructMenu()
end
function CharAnimViewer:setSpriteAndAnim(character, animationName)
self.sprite = Sprite("datas/gamedata/characters/" .. character .. "/sprites")
self.sprite:changeAnimation(animationName, true)
end
function CharAnimViewer:update(dt)
if (love.keyboard.isDown("z") and (not self.menusystem.isActive)) then
self.menusystem:activate()
end
if (self.sprite ~= nil) then
self.sprite:update(dt)
end
end
function CharAnimViewer:setBackground(newBackground)
self.background = Background(self, 5, 1, newBackground)
end
function CharAnimViewer:draw()
self.background:draw()
if (self.sprite ~= nil) then
self.sprite:drawAnimation(424/2, 240/1.5)
end
end
return CharAnimViewer