Hello, I'm not so familiar with Löve and I'm not sure what I'm doing wrong here..
I'll explain what's wrong, when I try fading an image it fades as it should, but for example when it's completly faded out it reappears for about a millisecond or something and then disappears, it's the same when fading it in but it disappears instead and then reappears..
Here's the code I'm using
function love.load()
--# Fading variables
fade = false;
fade_mode = nil;
fade_time = 5
fade_timer = 5
--# Load test image
image = love.graphics.newImage("logo.png")
end
function love.update(dt)
--# Handle fading
if fade then
--# Fade out
if fade_mode == "out" then
if fade_timer > 0 then
fade_timer = fade_timer - dt
else
if fade_timer < 0 then
fade_timer = 0
end
fade = false;
end
else
--# Fade in
if fade_timer < fade_time then
fade_timer = fade_timer + dt
else
if fade_timer > fade_time then
fade_timer = fade_time
end
fade = false;
end
end
end
end
function fadeOut( rate )
fade = true;
fade_mode = "out";
fade_timer = rate;
fade_time = rate;
end
function fadeIn( rate )
fade = true;
fade_mode = "in";
fade_time = rate;
end
function love.draw()
love.graphics.setColor(255, 255, 255, fade_timer*(255/fade_time))
love.graphics.draw(image, 100, 100)
end
function love.keypressed(key, unicode)
if key == "left" then
if fade_mode == "out" then
fadeIn(2)
else
fadeOut(2)
end
end
end
Note: My indenting of the code may get screwed up when pasting it here
What's the object-oriented way to get wealthy? Inheritance.
Even though this problem have been solved I have another question, But I don't want to start another topic for it since it's probably something simple. I'm wondering how I can invert a picture like this
I am not aware of one specific location, where stuff like this is documented. The wiki is very good in answer the question "What can a specific function do". However, to answer the question "What function do I need to achieve a certain thing", the wiki cannot help you directly. The usual approach here is to
Learn more and more over time and get a feeling for this
Ask people from the community, like you just did
Browse the wiki and read stuff, even if you are not looking for something specific. That way you more and more get an overview of what is possible. This is not the first thing you would do, when you learn LÖVE, because at that time you have no clue, what you really need.
In the beginning of course, it is most convenient to read tutorials and try to learn from code others write.
micha wrote:I am not aware of one specific location, where stuff like this is documented. The wiki is very good in answer the question "What can a specific function do". However, to answer the question "What function do I need to achieve a certain thing", the wiki cannot help you directly. The usual approach here is to
Learn more and more over time and get a feeling for this
Ask people from the community, like you just did
Browse the wiki and read stuff, even if you are not looking for something specific. That way you more and more get an overview of what is possible. This is not the first thing you would do, when you learn LÖVE, because at that time you have no clue, what you really need.
In the beginning of course, it is most convenient to read tutorials and try to learn from code others write.
Well I will mess around with LÖVE until I'm used to it, I feel like I've browsed the wiki one million times, but I might as well do it one million times more xP
Thanks for the help everyone!
What's the object-oriented way to get wealthy? Inheritance.