okay here is my question is there a code i can have
that got to do with real time countdown?
i have one that starts at any minute to 0
but the sad part its that when it hits like (10 secs)
it goes to a single number
scene 1
example ( 2:10)
example ( 2: 9) <-- don't want that!
example ( 2: 8) <-- don't want that!
example ( 0: 0) <-- don't want that!
scene 2
example ( 2:10)
example ( 2:09)<---- i want that
example ( 2:08)<---- i want that
example ( 0:00)<---- i want that
scene 1 is what i have BUT scene 2 is what i seek for.. can someone help me?????
real time count-down
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: real time count-down
You can use string.format when displaying the time to achieve this
For example:
Or, to format the minutes aswell:
For example:
Code: Select all
string.format("%02.0f",seconds)
Code: Select all
string.format("%02.0f:%02.0f",minutes,seconds)
Your screen is very zoomed in...
Re: real time count-down
?? how do i use that?
like can u give me an easy example?(code)
do i put that under load or update?
like can u give me an easy example?(code)
do i put that under load or update?
Re: real time count-down
You use this when you actually want to get a string representation of the timer.
For example if you are writing the timer in the top left corner of the screen you might do
Or if you are assigning the time to a variable for later use you might do
For example if you are writing the timer in the top left corner of the screen you might do
Code: Select all
love.graphics.print(string.format("%02.0f:%02.0f",minutes,seconds),0,0) --Print formatted time at 0,0
Code: Select all
local timerAsString = string.format("%02.0f:%02.0f",minutes,seconds)
Your screen is very zoomed in...
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: real time count-down
Or, y'know, simply:
Code: Select all
local timerAsString = string.format("%02d:%02d",minutes,seconds)
Help us help you: attach a .love.
Re: real time count-down
ugh can you do a .love with a simple countdown from 2:00 to 0:00
it will be a great help for me and also for who ever comes across this problem
it will be a great help for me and also for who ever comes across this problem
Re: real time count-down
I think this works, but I cannot test it right now. (You can just put this as main.lua and run it)
Code: Select all
function love.load()
time = 120 -- initial value in seconds
end
function love.update( dt )
time = time - dt -- make it count down
if time < 0 then
time = 0 -- make it stop at 0 in the sloppiest way possible
end
end
function love.draw()
local minutes = math.floor( time / 60 ) -- calculate how many minutes are left
local seconds = math.floor( time % 60 ) -- calculate how many seconds are left
love.graphics.print( string.format("%02d:%02d",minutes,seconds), 400, 300 ) -- print it somewhere near the middle of the screen with proper formatting
end
Re: real time count-down
it works i see thank you so much..
I need to learn more about TIME...
I need to learn more about TIME...
Who is online
Users browsing this forum: Bing [Bot] and 0 guests