Last active
June 5, 2019 10:53
-
-
Save swarnimarun/01951daa73a5eb6a2b95cddcd8e7ae9b to your computer and use it in GitHub Desktop.
Examples of Yield Function uses in GDScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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