Godot Best practices

编程入门 行业动态 更新时间:2024-10-08 12:40:32

<a href=https://www.elefans.com/category/jswz/34/1763636.html style=Godot Best practices"/>

Godot Best practices

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

更多推荐

Godot Best practices

本文发布于:2023-11-16 17:33:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1629627.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Godot   practices

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!