📜  gdscript assert - 任何代码示例

📅  最后修改于: 2022-03-11 15:00:01.398000             🧑  作者: Mango

代码示例1
# Imagine we always want speed to be between 0 and 20
speed = -10
assert(speed < 20) # True, the program will continue
assert(speed >= 0) # False, the program will stop
assert(speed >= 0 && speed < 20) # You can also combine the two conditional statements in one check
assert(speed < 20, "speed = %f, but the speed limit is 20" % speed) # Show a message with clarifying details