Hi, I'm new to LOVE 2D's lua... I have previous experience with some LUA, but I'm not sure how to do somethings.
Is there a wait() statement? or a way to delay something?
Thanks
(:
I'm new to LOVE lua
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- DaedalusYoung
- Party member
- Posts: 413
- Joined: Sun Jul 14, 2013 8:04 pm
Re: I'm new to LOVE lua
Well, there is love.timer.sleep(), but it's not recommended to use that, as it actually halts the entire program.
The common way of waiting is done by using states and a counter variable. Increase the counter every frame by dt until it reaches a certain value.
Example code:
The common way of waiting is done by using states and a counter variable. Increase the counter every frame by dt until it reaches a certain value.
Example code:
Code: Select all
love.load()
timer = 0
state = "wait"
end
love.update(dt)
if state == "wait" then
timer = timer + dt
if timer >= 5 then -- after 5 seconds
state = "continue" -- the game state is changed
end
end
end
love.draw()
if state == "wait" then
love.graphics.print("Not doing anything...", 64, 64) -- this message shows for the first 5 seconds
elseif state == "continue" then
love.graphics.print("Going to the next game state.", 64, 64) -- this message shows after that, until you quit LOVE
end
end
Who is online
Users browsing this forum: Ahrefs [Bot], Nikki and 5 guests