Say, make text saying "level 1" appear then after 3 seconds fade out or disappear and something else load?
Yes I know there is the update function but I need someone to walk me through how to use it because the documentation doesn't really help.
How can I make text disappear
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: How can I make text disappear
What do you mean the documentation isn't helpful? Maybe you're not using it right (I know how stupid it is to blame you for this so if you have any tips for the documentation then please lay them on us).
Anyway to make disappear you just have to change the color used to draw it.
Colors come in this simple format:
red, green, blue, alpha
Where each value can go from 0 (no color) to 255 (full color). These are conveniently passed to the function love.graphics.setColor:
So, if you want something to disappear, you just slowly decrease the amount of alpha until it's 0 (alpha determines how visible the color is, 255 being fully visible while 0 is invisible).
Here is a demo of it in action:
Anyway to make disappear you just have to change the color used to draw it.
Colors come in this simple format:
red, green, blue, alpha
Where each value can go from 0 (no color) to 255 (full color). These are conveniently passed to the function love.graphics.setColor:
Code: Select all
love.graphics.setColor(red, green, blue, alpha)
Here is a demo of it in action:
Code: Select all
function load()
love.graphics.setFont(love.graphics.newFont(love.default_font, 12)) -- a test font
alpha = 255
end
function update(dt)
alpha = alpha - (dt * (255 / 3)) -- so it takes 3 seconds to remove all the alpha
if alpha < 0 then alpha = 0 end -- to ensure that a 0 is the lowest value we get
end
function draw()
love.graphics.setColor(255,255,255,alpha) -- this would draw white and then fade out
love.graphics.draw("text", 100, 100)
end
Now posting IN STEREO (where available)
- keyspinner
- Prole
- Posts: 24
- Joined: Mon Sep 01, 2008 12:03 am
Re: How can I make text disappear
Well, the documentation doesn't help because I basically suck at understanding stuff. I need people to explain stuff to me.
Re: How can I make text disappear
I suck at explaining so we might have a clash here... did you understand what I said, though?
Now posting IN STEREO (where available)
- keyspinner
- Prole
- Posts: 24
- Joined: Mon Sep 01, 2008 12:03 am
Re: How can I make text disappear
Surprisingly, in a room full of chatting relatives, I did.
But now my keyreleased that goes to my next .lua doesn't load.
Do you want me to post my code?
But now my keyreleased that goes to my next .lua doesn't load.
Do you want me to post my code?
- qubodup
- Inner party member
- Posts: 775
- Joined: Sat Jun 21, 2008 9:21 pm
- Location: Berlin, Germany
- Contact:
Re: How can I make text disappear
no.keyspinner wrote:Do you want me to post my code?
Also known as "Don't ask to ask and ask."
So basically, yes.
lg.newImage("cat.png") -- made possible by lg = love.graphics
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
-- Don't force fullscreen (it frustrates those who want to try your game real quick) -- Develop for 1280x720 (so people can make HD videos)
- keyspinner
- Prole
- Posts: 24
- Joined: Mon Sep 01, 2008 12:03 am
Re: How can I make text disappear
You confused me, but I think I know what you mean.
main.lua
first.lua
Now, I want to be able to make first.lua's text (level 1) fade out and not come back then I want to make the player/level to fade in,
but when I put the fade thing in my first.lua it doesn't work.
main.lua
Code: Select all
function load()
font = love.graphics.newFont(love.default_font, 12)
love.graphics.setFont(font)
title = "lua demo"
play = "press space to play"
end
function draw()
love.graphics.draw(title, 50, 50)
love.graphics.draw(play, 400, 300)
end
function keyreleased(key)
if key == love.key_space then
love.filesystem.require("first.lua")
load()
end
end
first.lua
Code: Select all
function load()
love.graphics.setFont(love.graphics.newFont(love.default_font, 12))
alpha = 255
message = "Level 1"
player = love.graphics.newImage("player.jpg")
end
function draw()
love.graphics.setColor(255,255,255,alpha)
love.graphics.draw(message, 400, 300)
end
function update(dt)
alpha = alpha - (dt * (255 / 3))
if alpha > 0 then alpha = 0 end
end
but when I put the fade thing in my first.lua it doesn't work.
Re: How can I make text disappear
I'm pretty sleepy right know, but it would certainly help if you also posted the error LÖVE is throwing back at you. At least a screenshot of that lövely blue screen.
Teh Blog -> http://cryodreams.com.ar
- keyspinner
- Prole
- Posts: 24
- Joined: Mon Sep 01, 2008 12:03 am
Re: How can I make text disappear
I would love to post an error, but there is none, the keyreleased function just doesn't work.
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 2 guests