Rishav Sharan
06/03/2020, 12:20 PMvar breakTime = 3
var breakTimeText = text("Starting game in $breakTime seconds") {
position(10, 500)
addUpdater {
Count down to 0 in 1 sec intervals
update breakTime on each interval
if 0, then call function breakOver
}
}
i want the counter to go down to zero and then call a function. any tips on how I can achieve that?RezMike
06/03/2020, 12:31 PMvar breakTime = 3
val breakTimeText = text("Starting game in $breakTime seconds").position(10, 500)
launchImmediately {
while (breakTime > 0) {
println(breakTime)
breakTimeText.text = "Starting game in $breakTime seconds"
delay(1.seconds)
breakTime--
}
callFunction()
}
Rishav Sharan
06/03/2020, 12:41 PMRishav Sharan
06/03/2020, 12:55 PMSuspension functions can be called only within coroutine body
RezMike
06/03/2020, 12:58 PMRezMike
06/03/2020, 1:00 PMNico
06/03/2020, 1:21 PMit
in addUpdater has the timespan which passed since the last frame if that helps.