UI 基础
向你的游戏添加 UI 需要编写代码,但在 AI 的帮助下,制作复杂的交互式 UI 要容易得多
步骤 1:创建 UI 入口点
Player :: class : Player_Base {
ao_late_update :: method(dt: float) {
if this->is_local_or_server() {
draw_ui(this);
}
}
}步骤 2:从屏幕矩形开始
draw_ui :: proc(player: Player) {
screen := UI.get_safe_screen_rect();
// 一个简单的居中面板
panel := screen->center_rect()->grow(120, 200, 120, 200);
UI.quad(panel, core_globals.white_sprite, {0, 0, 0, 0.7});
}步骤 3:使用切割进行布局
步骤 4:添加文本
步骤 5:添加按钮
步骤 6:构建对话框
最后更新于