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

62 lines
1.6 KiB
Lua
Raw Permalink Normal View History

2021-11-25 10:57:13 +01:00
local Scene = require "game.scenes"
local menu = require "scenes.menus.debugmenus.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("assets.debug")
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.menus.main, "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:draw(424/2, 240/1.5)
end
end
return CharAnimViewer