Skip to content

Instantly share code, notes, and snippets.

@swarnimarun
Last active June 5, 2019 10:53
Show Gist options
  • Save swarnimarun/01951daa73a5eb6a2b95cddcd8e7ae9b to your computer and use it in GitHub Desktop.
Save swarnimarun/01951daa73a5eb6a2b95cddcd8e7ae9b to your computer and use it in GitHub Desktop.
Examples of Yield Function uses in GDScript
extends Node
func my_yielding_function():
print("Hello")
print(yield())
print("World")
func _ready():
var v = my_yielding_function()
v.resume("Awesome")
# **This will print**
#
# Hello
# Awesome
# World
extends Node
func my_timer_function():
print("Hello")
yield(get_tree().create_timer(2.0), "timeout")
print("World")
func _ready():
my_timer_function()
print("Awesome")
# **This will print**
#
# Hello
# Awesome
# World
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment