Page 1 of 1

Making a dialog. Drawing texts and removing them

Posted: Sat Jun 07, 2014 12:28 pm
by dado_eyad
Hello,

I'm trying to make a game where I have two characters, when the controlled character reaches a certain point an automatic dialog should appear between the two characters. These texts should appear for like 2 seconds for example and disappear after.
Can anyone point me in the direction on how to implement that?
I've attached the game file.

Thanks in advance!

Re: Making a dialog. Drawing texts and removing them

Posted: Sat Jun 07, 2014 8:43 pm
by Ranguna259
Welcome to the forum dado :)
To do that you'll need to code a timer or use a timer lib, cron.lua for exemple, and after X seconds the text would disappear, you can do that by making a variable that, when true, the game draws the text and when false it doesn't.

Here's an exemple using cron:

Code: Select all

cron = require 'cron'

function love.load()
  counter = cron.after(2,function() show = false end)
  show = true
end

function love.update(dt)
  counter:update(dt)
end

function love.draw()
  if show then
    love.graphics.draw('hello',1,1)
  end
end
This code will make 'hello' appear on the screen for 2 seconds, after that the text will disappear.

You can also use text libs like this one