Refonte pour utiliser le systeme de GUI #112
1 changed files with 0 additions and 91 deletions
|
@ -1,91 +0,0 @@
|
|||
local GameOverScreen = Object:extend()
|
||||
|
||||
local TweenManager = require "birb.classes.time"
|
||||
local ConfirmDialog = require "game.modules.confirmdialog"
|
||||
|
||||
local defTransitions = require "birb.modules.transitions"
|
||||
local radTransitions = require "game.modules.transitions"
|
||||
|
||||
local gui = require "game.modules.gui"
|
||||
|
||||
local tw, th = 128, 32
|
||||
|
||||
function GameOverScreen:new(scene)
|
||||
self.scene = scene
|
||||
self.assets = scene.assets
|
||||
self.turnSystem = scene.turns
|
||||
|
||||
self:setVariables()
|
||||
|
||||
self.continueBox = gui.newTextBox("assets/gui/dialogbox.png", tw, th)
|
||||
|
||||
self.tweens = TweenManager(self)
|
||||
self:prepareAnimation()
|
||||
end
|
||||
|
||||
function GameOverScreen:setVariables()
|
||||
-- Vignette Opacity
|
||||
self.vignetteOpacity = 0
|
||||
|
||||
-- Battle FInished Label
|
||||
self.labelOpacity = 0
|
||||
local width, height = core.screen:getDimensions()
|
||||
self.labelX = width/2
|
||||
|
||||
-- Infobox
|
||||
self.tbSize = 0.6
|
||||
self.tbOpacity = 0
|
||||
end
|
||||
|
||||
function GameOverScreen:prepareAnimation()
|
||||
-- Vignette
|
||||
self.tweens:newTween(0, 0.6, {vignetteOpacity=0.75}, 'inExpo')
|
||||
|
||||
-- Label
|
||||
self.tweens:newTween(0, 0.6, {labelOpacity=1}, 'inExpo')
|
||||
self.tweens:newTween(0.9, 0.4, {labelX=4}, 'inExpo')
|
||||
|
||||
self.tweens:newTimer(1.8, "continue")
|
||||
end
|
||||
|
||||
function GameOverScreen:update(dt)
|
||||
self.tweens:update(dt)
|
||||
end
|
||||
|
||||
function GameOverScreen:draw()
|
||||
local width, height = core.screen:getDimensions()
|
||||
self:drawVignette(width, height)
|
||||
self:drawLabel(width/2, 48, self.labelX, self.labelOpacity)
|
||||
end
|
||||
|
||||
function GameOverScreen:timerResponse(timer)
|
||||
if (timer == "continue") then
|
||||
local confirm = ConfirmDialog(self.scene, "Do you want to return to title ? \nYou can also reload your latest save.",
|
||||
function() self:returnToTitle() end, "Return to title",
|
||||
function() self:loadLastSave() end, "Reload last save")
|
||||
confirm.darken = false
|
||||
end
|
||||
end
|
||||
|
||||
function GameOverScreen:drawVignette(width, height)
|
||||
love.graphics.setColor(0, 0, 0, self.vignetteOpacity)
|
||||
love.graphics.rectangle("fill", 0, 0, width, height)
|
||||
end
|
||||
|
||||
function GameOverScreen:drawLabel(x, y, x2, opacity)
|
||||
love.graphics.setColor(1, 1, 1, opacity)
|
||||
|
||||
self.assets.fonts["SA2font"]:print("GAME", x - x2, y, "right")
|
||||
self.assets.fonts["SA2font"]:print("OVER", x + x2, y, "left")
|
||||
end
|
||||
|
||||
function GameOverScreen:returnToTitle()
|
||||
core.screen:startTransition(defTransitions.default, defTransitions.circle, function() scenes.menus.title(true) end, 424/2, 240/2)
|
||||
end
|
||||
|
||||
function GameOverScreen:loadLastSave()
|
||||
self.scene.tweens:newTween(0, 0.3, {borderPosition=0}, "inOutQuad")
|
||||
core.screen:startTransition(defTransitions.default, defTransitions.default, function() game:reload() scenes.overworld() end, 424/2, 240/2)
|
||||
end
|
||||
|
||||
return GameOverScreen
|
Loading…
Reference in a new issue