feat: add message engine on overworld

This commit is contained in:
Kazhnuz 2021-03-20 17:10:09 +01:00
parent c8803585a1
commit f7f1a772f7

View file

@ -32,6 +32,8 @@ local screens = require "scenes.overworld.screens"
local gui = require "game.modules.gui"
local TweenManager = require "game.modules.tweenmanager"
local PLAYER_MESSAGE = 240 - 32
function MovePlayer:new()
MovePlayer.super.new(self)
self.charsetManager = CharsetManager(self)
@ -56,6 +58,15 @@ function MovePlayer:new()
self.emblemPosition = 368
self.ringBorder = 16
self.timeBorder = -10
self.message = "Test de message"
self.messageOpacity = 0
end
function MovePlayer:showMessage(message)
self.message = message
self.messageOpacity = 1
self.tweens:newTween(0, 0.2, {messageOpacity = 1}, 'inOutCubic')
self.tweens:newTween(1, 0.2, {messageOpacity = 0}, 'inOutCubic')
end
function MovePlayer:registerScreen(screen)
@ -141,6 +152,15 @@ function MovePlayer:draw()
if (self.currentScreen ~= nil) then
self.currentScreen:drawForeground()
end
love.graphics.setColor(0,0,0, 0.5 * self.messageOpacity)
love.graphics.rectangle("fill", 0, PLAYER_MESSAGE, 424, 16)
if (self.messageOpacity > 0) then
self.assets.fonts["small"]:setColor(1,1,1, self.messageOpacity)
self.assets.fonts["small"]:draw(self.message, 424/2, PLAYER_MESSAGE - 1, -1, "center")
self.assets.fonts["small"]:setColor(1,1,1, 1)
end
utils.graphics.resetColor()
end
return MovePlayer