Making a dialog. Drawing texts and removing them

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
dado_eyad
Prole
Posts: 1
Joined: Sat Jun 07, 2014 12:20 pm

Making a dialog. Drawing texts and removing them

Post 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!
Attachments
game.love
(5.62 KiB) Downloaded 110 times
User avatar
Ranguna259
Party member
Posts: 911
Joined: Tue Jun 18, 2013 10:58 pm
Location: I'm right next to you

Re: Making a dialog. Drawing texts and removing them

Post 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
LoveDebug- A library that will help you debug your game with an on-screen fully interactive lua console, you can even do code hotswapping :D

Check out my twitter.
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests