feat: ajout d'un viewer des animations
This commit is contained in:
parent
72cccdcaf2
commit
4a8ea25b7e
4 changed files with 83 additions and 1 deletions
|
@ -2,6 +2,7 @@ return {
|
|||
menu = require "scenes.debug.menu",
|
||||
viewers = {
|
||||
battleBack = require "scenes.debug.viewers.battleBack",
|
||||
choregraphy = require "scenes.debug.viewers.choregraphy"
|
||||
choregraphy = require "scenes.debug.viewers.choregraphy",
|
||||
animation = require "scenes.debug.viewers.animation",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ function DebugMenu:buildBattleMenu()
|
|||
end
|
||||
|
||||
menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.battleBack, "Background Viewer")
|
||||
menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.animation, "Animation Viewer")
|
||||
menu.commons.SceneWidget(self, "combat", scenes.debug.viewers.choregraphy, "Ennemies' Action Viewer")
|
||||
end
|
||||
|
||||
|
|
61
sonic-radiance.love/scenes/debug/viewers/animation/init.lua
Normal file
61
sonic-radiance.love/scenes/debug/viewers/animation/init.lua
Normal file
|
@ -0,0 +1,61 @@
|
|||
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
|
19
sonic-radiance.love/scenes/debug/viewers/animation/menu.lua
Normal file
19
sonic-radiance.love/scenes/debug/viewers/animation/menu.lua
Normal file
|
@ -0,0 +1,19 @@
|
|||
local commons = require "scenes.debug.commons.menu"
|
||||
local listMenu = require "game.modules.menus.list"
|
||||
local menu = {}
|
||||
menu.commons = commons
|
||||
menu.AnimationWidget = listMenu.DualTextWidget:extend()
|
||||
|
||||
-- ShowBackground
|
||||
function menu.AnimationWidget:new(scene, menuName, animName)
|
||||
menu.AnimationWidget.super.new(self, scene, menuName, animName, "")
|
||||
self.charName = menuName
|
||||
self.animName = animName
|
||||
end
|
||||
|
||||
function menu.AnimationWidget:action()
|
||||
self.scene:setSpriteAndAnim(self.charName, self.animName)
|
||||
self.scene.menusystem:deactivate()
|
||||
end
|
||||
|
||||
return menu
|
Loading…
Reference in a new issue