0

In Gdscript for Godot there was code line that waits for 1 second and then continues the code.

yield(get_tree().create_timer(1),"timeout")

How can i achieve same usage in Kotlin in Android Studio?

Serdar Çivi
  • 181
  • 1
  • 8
  • 3
    Does this answer your question? [Kotlin - Wait function](https://stackoverflow.com/questions/45213706/kotlin-wait-function) – maio290 Apr 29 '21 at 13:56
  • I don't have experience with Kotlin. However, for people answering know that the presented GDScript code makes the function a Coroutine, it is non-blocking (similar to `async/await`). It is NOT sleep. After searching online, I believe the equivalent in Kotlin is `delay` on a function with `suspend`. – Theraot Apr 29 '21 at 14:01
  • Yes @Theraot is correct, but you could also use an Android `Handler` to post delayed code. But there are hundreds of duplicates of this. – Henry Twist Apr 29 '21 at 14:52
  • Does this answer your question? [How to call a method after a delay in Android](https://stackoverflow.com/questions/3072173/how-to-call-a-method-after-a-delay-in-android) – Ryan M Aug 23 '21 at 23:29

0 Answers0