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

62 lines
1.6 KiB
Lua
Raw Normal View History

local Scene = require "game.scenes"
2021-08-15 16:26:05 +02:00
local menu = require "scenes.menus.debugmenus.animation.menu"
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.assets:batchImport("assets.debug")
2021-07-04 11:43:46 +02:00
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
2021-08-15 16:26:05 +02:00
menu.commons.SceneWidget(self, "MainMenu", scenes.menus.main, "Back")
2021-07-04 11:43:46 +02:00
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