Page 2 of 2

Re: Wait/Pause/Sleep?

Posted: Sun Apr 07, 2013 2:27 pm
by Jackim
Can you upload a .love file?

Re: Wait/Pause/Sleep?

Posted: Sun Apr 07, 2013 6:11 pm
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.

Re: Wait/Pause/Sleep?

Posted: Sun Apr 07, 2013 9:02 pm
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!

Re: Wait/Pause/Sleep?

Posted: Mon Apr 08, 2013 12:20 am
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.

Re: Wait/Pause/Sleep?

Posted: Mon Apr 08, 2013 4:01 am
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.

Re: Wait/Pause/Sleep?

Posted: Mon Apr 08, 2013 4:09 am
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?

Re: Wait/Pause/Sleep?

Posted: Mon Apr 08, 2013 7:34 am
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.