i tried using
local score=0
function yes()
score = score+1
end
timer.performwithDelat(1000,yes,0)
this results in 1,3,6,10… why wont it just give me 1,2,3,4. also i tried using score++ or score+=1 but it keeps giving me an error
i tried using
local score=0
function yes()
score = score+1
end
timer.performwithDelat(1000,yes,0)
this results in 1,3,6,10… why wont it just give me 1,2,3,4. also i tried using score++ or score+=1 but it keeps giving me an error
I don’t believe that at all. First off, ‘performwithDelat’ is not a function, so either you’ve added a function to the timer library and it’s working incorrectly or you’re not getting your debug values out the right way.
Please post the actual code you have and please use the code button between the picture and quote button in the text editor when posting to the forum.
Example:
local score = 0 function incScore() score = score + 1 print(score) end timer.performWithDelay( 1000, incScore )
i found the problem, i used the print(score) and it showed everything in order; 1,2,3,4,5… but when i show it on the screen;
total= display.newtext(…)
total.text = score;
it dosent update properly
Again, I still don’t believe it. You are not providing your actual code and still not using the Post Code button in the toolbar.
Another example:
local text = display.newText{ x=100, y=100, fontSize=26, text="" } local score = 0 function incScore() score = score + 1 print(score) text.text = text.text .. ", " .. score end timer.performWithDelay( 1000, incScore )
Lua does not support C style auto increment and decrement operators. You cannot use var++ or var += 1.
i found the problem.
i added a third parameter
e.x timer.performWithDelay( 1000, incScore,-1 )
i deleted that parameter and only kept the first two
so now i am left with
timer.performWithDelay( 1000, incScore )
if possible, can anyone explain why adding a third parameter messed it up?
thx hora and rob for your help
Putting -1 in the third param loops it.
See: https://docs.coronalabs.com/api/library/timer/performWithDelay.html#iterations-optional
I don’t believe that at all. First off, ‘performwithDelat’ is not a function, so either you’ve added a function to the timer library and it’s working incorrectly or you’re not getting your debug values out the right way.
Please post the actual code you have and please use the code button between the picture and quote button in the text editor when posting to the forum.
Example:
local score = 0 function incScore() score = score + 1 print(score) end timer.performWithDelay( 1000, incScore )
i found the problem, i used the print(score) and it showed everything in order; 1,2,3,4,5… but when i show it on the screen;
total= display.newtext(…)
total.text = score;
it dosent update properly
Again, I still don’t believe it. You are not providing your actual code and still not using the Post Code button in the toolbar.
Another example:
local text = display.newText{ x=100, y=100, fontSize=26, text="" } local score = 0 function incScore() score = score + 1 print(score) text.text = text.text .. ", " .. score end timer.performWithDelay( 1000, incScore )
Lua does not support C style auto increment and decrement operators. You cannot use var++ or var += 1.
i found the problem.
i added a third parameter
e.x timer.performWithDelay( 1000, incScore,-1 )
i deleted that parameter and only kept the first two
so now i am left with
timer.performWithDelay( 1000, incScore )
if possible, can anyone explain why adding a third parameter messed it up?
thx hora and rob for your help
Putting -1 in the third param loops it.
See: https://docs.coronalabs.com/api/library/timer/performWithDelay.html#iterations-optional