当前位置:首页 > 编程笔记 > 正文
已解决

Godot Best practices

来自网友在路上 166866提问 提问时间:2023-11-06 06:10:51阅读次数: 66

最佳答案 问答题库668位专家为你答疑解惑

Get Forward Vector

transform.x
# 等价手算
var rad = node.rotation
var forward = Vector2(cos(rad), sin(rad))

Await and Unity Style Coroutine

func coroutine(on_update: Callable, duration: float = 1):var elapse_time = 0while elapse_time < 1:elapse_time += get_process_delta_time() / durationon_update.call(elapse_time)await get_tree().process_frame # 等待下一帧# normal call - 后续逻辑会在 while loop 执行一次后立刻执行
coroutine(func(): print("do coroutine"))
# test debug
start
do coroutine
end
do coroutine
do coroutine
...
# await call - 后续逻辑会等到 coroutine 执行完成之后才会执行
await coroutine(func(): print("do coroutine"))
# test debug
start
do coroutine
do coroutine
...
end
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"Godot Best practices":http://eshow365.cn/6-33390-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!