OK so i am setting up timers and i have one that counts down but i cant get the other one to get down. Here are the codes i am using for both of them.
timer 1 (works)
local countdowntxt = display.newText(time\_remain, 0, 0, "Times New Roman", 16\*2);
countdowntxt.xScale = 1; countdowntxt.yScale = 1;
countdowntxt:setReferencePoint(display.CenterRightReferencePoint);
countdowntxt.x = \_W-20; countdowntxt.y = \_H-20;
local function countDown(e)
time\_remain = time\_remain - 1;
countdowntxt.text = time\_remain;
end
if(o == total\_mints) then
gametmr = timer.performWithDelay(1000, countDown, 1814400)
end
And The one for the second timer that doesnt work.
local countdowntxt = display.newText(time\_remain2, 0, 0, "Times New Roman", 16\*2);
countdowntxt.xScale = 1; countdowntxt.yScale = 1;
countdowntxt:setReferencePoint(display.CenterLeftReferencePoint);
countdowntxt.x = \_W-460; countdowntxt.y = \_H-20;
local function countDown(e)
time\_remain2 = time\_remain2 - 1;
countdowntxt.text = time\_remain2;
end
if(o == time\_remain2) then
gametmr = timer.performWithDelay(60000, counDown, 30240)
end
Any help would be greatly appreciated. [import]uid: 69054 topic_id: 18623 reply_id: 318623[/import]
OK on line 16 is when the second timer code starts [import]uid: 69054 topic_id: 18623 reply_id: 71524[/import]
Is this all of the code?
I don’t see where o,time_remain2, total_mints, or time_remain are given any starting values.
and adding < /code > tag will end the code areas. [import]uid: 94868 topic_id: 18623 reply_id: 71528[/import]
Hey there, have fixed up the tags in your post.
You want to use < code > as you were before the code but at the end, do < /code > to go back to normal text. (Without the spaces of course.)
As Screaming Leaf said it would help to see some more code.
I do see a typo that may be causing the problem, however that should have printed in the terminal. (Are you using the terminal?)
Anyway, line 12 - you write “counDown” rather than “countDown”.
Peach
[import]uid: 52491 topic_id: 18623 reply_id: 71531[/import]
Yes i am using the console and i had noticed that typo a few minutes after i posted the post. And i am not using a starting value for 0 or total_mints, cause i all i want to do is make the timer run and it seems to do that without those values but here are the codes for time_remain and time_remain2.
time\_remain = 1814400
time\_remain2 = 30240
I guess the problem could be because i dont have 0 and total_mint values. [import]uid: 69054 topic_id: 18623 reply_id: 71670[/import]
Oh just adding 0 = 1 and total_mints = 1 got it to work
thank you for your help and i’m sure i will be back with mroe questions later. [import]uid: 69054 topic_id: 18623 reply_id: 71672[/import]
Glad all is well now - I look forward to seeing your other questions around the forum.
Peach
[import]uid: 52491 topic_id: 18623 reply_id: 71771[/import]
Thank you again. [import]uid: 69054 topic_id: 18623 reply_id: 71775[/import]