I'm sorta new at lua so please don't hate. I'm trying to make an image stay visible for 10 seconds then disappear. Here are the functions I put in...
function love.draw()
love.graphics.setColor( 255, 255, 255, 255 )
love.graphics.draw( imageLevel1, 300, 60, 0, 0.7 ) while true do love.timer.sleep(10).love.graphics.draw( imageLevel1, 300, 60, 0, 0.7 ) while true do imageLevel1 = love.graphics.newImage( "textures/level1.png" )(bool) end end
Help with sleep function
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Help with sleep function
Firstly, use [ code] [/ code] tags to format your code. Secondly, love.timer.sleep will cause the entire program to freeze until it's done sleeping. Thirdly, you should only call newImage once, and use it many times to draw, and lastly your code is doing some weird stuff man.
Here's one way I might make an image stay visible for 10 seconds (there are several similar ways to do this):
Here's one way I might make an image stay visible for 10 seconds (there are several similar ways to do this):
Code: Select all
-- love.load will be executed once when the game first starts up.
function love.load()
imageLevel1 = love.graphics.newImage("textures/level1.png")
drawtime = 0
end
function love.update(dt)
drawtime = drawtime + dt
end
function love.draw()
if drawtime <= 10 then
love.graphics.draw(imageLevel1, 300, 60)
end
end
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google Adsense [Bot] and 18 guests