Wait/Pause/Sleep?

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.
Jackim
Prole
Posts: 12
Joined: Wed Apr 03, 2013 3:02 am
Location: Canada

Re: Wait/Pause/Sleep?

Post by Jackim »

Can you upload a .love file?
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Wait/Pause/Sleep?

Post by T-Bone »

You're not putting dt as argument to the love.draw function, are you? It should be to love.update, nothing else.
Knuxchan
Prole
Posts: 15
Joined: Wed Apr 03, 2013 4:06 am

Re: Wait/Pause/Sleep?

Post by Knuxchan »

T-Bone wrote:You're not putting dt as argument to the love.draw function, are you? It should be to love.update, nothing else.
Nope. It's only in the update function, and that's all. I put this line in the update function:

Code: Select all

 love.graphics.print(dt, 100, 200)
When that didn't work, I put the same line in the draw() function. It didn't show anything at first, but as I was editing the x,y, coordinate of where I wanted the text shown, the text suddenly appeared, but it keeps saying '0.003', It doesn't change.
Jackim wrote:Can you upload a .love file?
Done!
Attachments
testgame.love
(79.36 KiB) Downloaded 198 times
Jackim
Prole
Posts: 12
Joined: Wed Apr 03, 2013 3:02 am
Location: Canada

Re: Wait/Pause/Sleep?

Post by Jackim »

The way you've set up your code, for whatever reason, makes it so dt doesn't work in your update function.

I put it in the love.update built in function and it works fine.
Attachments
fixed.love
(80.5 KiB) Downloaded 182 times
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Wait/Pause/Sleep?

Post by Jasoco »

Plu wrote:It's probably a better idea to do

Code: Select all

love.timer.sleep( 5 )
The above would keep the CPU running all the time, which probably isn't neccesary.
No. Don't do this. It's better to use or design a timer library and use those. I threw my own together for use in my own game and there's a few here you can use.
Knuxchan
Prole
Posts: 15
Joined: Wed Apr 03, 2013 4:06 am

Re: Wait/Pause/Sleep?

Post by Knuxchan »

Jackim wrote:The way you've set up your code, for whatever reason, makes it so dt doesn't work in your update function.

I put it in the love.update built in function and it works fine.
Thank you! So if I understand correctly, for anything that requires timers or the utilization of 'dt' I will need to always put those calculations in the actual built-in update function instead of the 'pcall' one?
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Wait/Pause/Sleep?

Post by T-Bone »

Yes, that's correct. If you want to call other functions that use dt, call them from within love.update and pass on dt as an argument.

Love.timer.sleep is, as far as I know, mainly used in threads that aren't the main thread.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests