Refonte pour utiliser le systeme de GUI #112
4 changed files with 79 additions and 79 deletions
|
@ -1,22 +1,25 @@
|
|||
local Scene = require("game.scenes")
|
||||
local PlayStyle = Scene:extend()
|
||||
|
||||
local PauseMenu = require("game.modules.subgames.pause")
|
||||
local TweenManager = require "birb.classes.time"
|
||||
local PauseScreen = require("game.modules.subgames.pause")
|
||||
local TestWorld = require("game.modules.subgames.world.parent")
|
||||
|
||||
function PlayStyle:new(supportedLevels, missionfile)
|
||||
PlayStyle.super.new(self)
|
||||
PlayStyle.super.new(self, false, false)
|
||||
self.timer = 0
|
||||
self.assets:batchImport("assets.subgames")
|
||||
--self:loadMissionFile(supportedLevels, missionfile)
|
||||
|
||||
PauseMenu(self)
|
||||
|
||||
self:initWorld()
|
||||
self:initMission()
|
||||
self:initCharacters()
|
||||
|
||||
self.tweens = TweenManager(self)
|
||||
PauseScreen()
|
||||
|
||||
self.haveStarted = false
|
||||
self.canPause = true
|
||||
end
|
||||
|
||||
function PlayStyle:loadMissionFile(supportedLevels, missionfile)
|
||||
|
@ -51,26 +54,48 @@ function PlayStyle:update(dt)
|
|||
end
|
||||
|
||||
function PlayStyle:updatePauseMenus(dt)
|
||||
if self.menusystem.menus["pauseMenu"].isActive == false then
|
||||
self.tweens:update(dt)
|
||||
if self.gui.screens["pauseScreen"].isVisible == false then
|
||||
self.timer = self.timer + dt
|
||||
end
|
||||
|
||||
local keys = self:getKeys(1);
|
||||
|
||||
if keys["start"].isPressed then
|
||||
if not (self.menusystem.menus["pauseMenu"].isActive) then
|
||||
self.menusystem.menus["pauseMenu"].isActive = true
|
||||
self.menusystem.menus["pauseMenu"].isVisible = true
|
||||
self.menusystem.menus["pauseMenu"]:getFocus()
|
||||
self.assets.isActive = false
|
||||
self.world.isActive = false
|
||||
|
||||
if (keys["start"].isPressed and self.canPause) then
|
||||
if (not self.isPaused) then
|
||||
if (not self.gui.screens["overlay"].isVisible) then
|
||||
self.assets.sfx["mSelect"]:play()
|
||||
self:pause()
|
||||
end
|
||||
else
|
||||
self.menusystem.menus["pauseMenu"].isActive = false
|
||||
self.menusystem.menus["pauseMenu"].isVisible = false
|
||||
self.assets.isActive = true
|
||||
self.assets.sfx["mBack"]:play()
|
||||
self:unpause()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function PlayStyle:timerResponse(timer)
|
||||
if (timer == "unPause") then
|
||||
self.isPaused = false
|
||||
self.world.isActive = true
|
||||
end
|
||||
end
|
||||
|
||||
function PlayStyle:pause()
|
||||
self.gui:showScreen("overlay")
|
||||
self.gui:showScreen("pauseScreen")
|
||||
self.gui:playScreenTransform("overlay", "showBackgroundPause")
|
||||
self.isPaused = true
|
||||
self.world.isActive = false
|
||||
end
|
||||
|
||||
function PlayStyle:unpause()
|
||||
self.tweens:newTimer(0.2, "unPause")
|
||||
self.gui:playScreenTransform("overlay", "hideBackgroundPause")
|
||||
self.gui:hideScreen("overlay")
|
||||
self.gui:hideScreen("pauseScreen")
|
||||
end
|
||||
|
||||
function PlayStyle:startLevel()
|
||||
|
@ -80,6 +105,7 @@ function PlayStyle:startLevel()
|
|||
end
|
||||
|
||||
function PlayStyle:restartLevel()
|
||||
self:unpause()
|
||||
self.world:reset()
|
||||
end
|
||||
|
||||
|
|
|
@ -1,63 +1,45 @@
|
|||
local RadianceListMenu = require "game.modules.menus.list"
|
||||
local PauseMenu = RadianceListMenu.ListMenu:extend()
|
||||
local PauseScreen = require("birb.modules.gui.screen"):extend()
|
||||
|
||||
local ResumeWidget = RadianceListMenu.DualTextWidget:extend()
|
||||
local RestartWidget = RadianceListMenu.DualTextWidget:extend()
|
||||
local ExitWidget = RadianceListMenu.DualTextWidget:extend()
|
||||
local BoxedMenu = require("game.modules.gui.boxedmenu")
|
||||
local TextElement = require("birb.modules.gui.elements.text")
|
||||
|
||||
local WIDTH = 80
|
||||
local X, Y, TXT_Y = 424/2, 240/2, 240/6
|
||||
local OX, OY = WIDTH/2, (3*17)/2
|
||||
|
||||
function PauseMenu:new(subgame)
|
||||
local x, y
|
||||
x = 424/2 - WIDTH/2
|
||||
y = 240/2 - (3*17)/2
|
||||
local show = {
|
||||
{"pauseMenu", "tween", 0.1, 0.3, {opacity = 1, sx = 1, sy = 1}, "inOutQuart"},
|
||||
{"pauseText", "tween", 0.1, 0.3, {opacity = 1, y = TXT_Y}, "inOutQuart"},
|
||||
}
|
||||
|
||||
PauseMenu.super.new(self, subgame, "pauseMenu", x, y, WIDTH, 3, true)
|
||||
local hide = {
|
||||
{"pauseMenu", "tween", 0, 0.3, {opacity = 0, sx = 0.8, sy = 0.8}, "inOutQuart"},
|
||||
{"pauseText", "tween", 0, 0.3, {opacity = 0, y = TXT_Y - 16}, "inOutQuart"},
|
||||
}
|
||||
|
||||
self:setSound(self.scene.assets.sfx["navigate"])
|
||||
self.isActive = false
|
||||
self.isVisible = false
|
||||
|
||||
ResumeWidget(subgame)
|
||||
self:setCancelWidget()
|
||||
RestartWidget(subgame)
|
||||
ExitWidget(subgame)
|
||||
function PauseScreen:new()
|
||||
PauseScreen.super.new(self, "pauseScreen")
|
||||
self:addTransform("show", show)
|
||||
self:addTransform("hide", hide)
|
||||
self.defaultFocus = "pauseMenu"
|
||||
end
|
||||
|
||||
--- MENU WIDGETS
|
||||
function PauseScreen:createElements()
|
||||
local pauseMenu = BoxedMenu("pauseMenu", X, Y, WIDTH, 3, true, false)
|
||||
pauseMenu:addItem("Resume", "left", function() self.scene:unpause() end, "back")
|
||||
pauseMenu:setCancelWidget()
|
||||
pauseMenu:addItem("Restart", "left", function() self.scene:restartLevel() end, "back")
|
||||
pauseMenu:addItem("Exit", "left", function() self.scene:exitLevel() end, "back")
|
||||
pauseMenu.opacity = 0
|
||||
pauseMenu.sx, pauseMenu.sy = 0.8, 0.8
|
||||
pauseMenu.ox, pauseMenu.oy = OX, OY
|
||||
|
||||
function ResumeWidget:new(scene)
|
||||
ResumeWidget.super.new(self, scene, "pauseMenu", "Resume", "")
|
||||
local text = TextElement("pauseText", "SA2font", "Pause", X, TXT_Y - 16, "center")
|
||||
text.opacity = 0
|
||||
return {
|
||||
{pauseMenu, 0, 1},
|
||||
{text, 0, 1}
|
||||
}
|
||||
end
|
||||
|
||||
function ResumeWidget:action()
|
||||
self.menu.isActive = false
|
||||
self.menu.isVisible = false
|
||||
self.scene.world.isActive = true
|
||||
self.scene.assets.isActive = true
|
||||
self.scene:flushKeys()
|
||||
end
|
||||
|
||||
function RestartWidget:new(scene)
|
||||
ResumeWidget.super.new(self, scene, "pauseMenu", "Restart", "")
|
||||
end
|
||||
|
||||
function RestartWidget:action()
|
||||
self.scene:restartLevel()
|
||||
self.menu.isActive = false
|
||||
self.menu.isVisible = false
|
||||
self.scene.world.isActive = true
|
||||
self.scene.assets.isActive = true
|
||||
self.scene:flushKeys()
|
||||
end
|
||||
|
||||
function ExitWidget:new(scene)
|
||||
ExitWidget.super.new(self, scene, "pauseMenu", "Exit", "")
|
||||
end
|
||||
|
||||
function ExitWidget:action()
|
||||
self.scene:exitLevel()
|
||||
end
|
||||
|
||||
|
||||
return PauseMenu
|
||||
return PauseScreen
|
|
@ -2,8 +2,6 @@ local cwd = (...):gsub('%.player$', '') .. "."
|
|||
local Parent = require(cwd .. "parent")
|
||||
local Player = Parent:extend()
|
||||
|
||||
local Emblem = require "game.modules.gui.emblem"
|
||||
|
||||
function Player:new(world, x, y, z, id)
|
||||
Player.super.new(self, world, "player", x, y, 0, 16, 12, 24, true)
|
||||
self:setGravity(480*2)
|
||||
|
@ -20,9 +18,6 @@ function Player:initPlayer()
|
|||
self.charName = game.characters:getActiveCharacter()
|
||||
self.assets:addSprite(self.charName, "datas/gamedata/characters/" .. self.charName .. "/sprites")
|
||||
self:setSprite(self.charName, true, 8, 10)
|
||||
|
||||
self.emblem = Emblem(game.characters:getActiveCharacterData(), self.scene)
|
||||
self.guiborder = game.gui.newBorder(424, 20, 6)
|
||||
end
|
||||
|
||||
function Player:updateStart(dt)
|
||||
|
@ -115,11 +110,6 @@ function Player:draw()
|
|||
Player.super.draw(self)
|
||||
end
|
||||
|
||||
function Player:drawHUD(id)
|
||||
love.graphics.draw(self.guiborder, 0, 20, 0, 1, -1)
|
||||
self.emblem:draw(424 - 40, 12)
|
||||
end
|
||||
|
||||
function Player:setRing(value, isRelative)
|
||||
if (isRelative == false) then
|
||||
self.rings = 0
|
||||
|
|
|
@ -5,7 +5,9 @@ local GFX_DIRECTORY = "assets/sprites/gfx/"
|
|||
function GFX:new(world, x, y, z, spritename, creator, blockProcess, tag)
|
||||
GFX.super.new(self, world, x, y, z)
|
||||
|
||||
if (creator.choregraphy ~= nil) then
|
||||
self.char = self:getCharacter(creator.choregraphy.fighter)
|
||||
end
|
||||
self:setAnimation(spritename)
|
||||
|
||||
self.creator = creator
|
||||
|
|
Loading…
Reference in a new issue