Add Safe Area example

未关闭
#146 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
lua
领域
mobile-dev

调研方向

未指定文件或测试。首先查看现有示例以及 issue 中描述的 Safe Area API,包括 gui.safe_area_mode、gui.gui.set_safe_area_mode() 和 window.get_safe_area()。完成的标准是提供一个可运行的示例,演示在 Android 和 iOS 上实现考虑 Safe Area 的布局。

由索引模型根据 Issue 内容生成。

描述

example

Describe the example you'd like
Safe Area is built-in since Defold 1.12.1

Safe Area support for Android and iOS phones is now available in the engine out of the box.
You can control how the GUI respects the safe area using gui.safe_area_mode = none|long|short|both in game.project, with the option to override this per GUI scene at runtime via gui.gui.set_safe_area_mode(gui.SAFE_AREA_*).

This allows UI elements to stay within safe zones on devices with notches, while still using the full screen when no cutout is present (On platforms without cutouts, the inset values are returned as 0).
The new window.get_safe_area() API provides the current safe area rectangle along with inset values, making it possible to use this data in custom layout and positioning logic.

Additional context (optional)
Here you can specify references (screenshots, links) of what you would like to see in the example.

主要语言
Lua
星标
130
派生
36
平均合并
1 天 3 小时
30 天内合并 PR
9

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

defold/examples 的其他 Issue

查看 defold/examples 的全部 Issue

相似的 Issue

更多 Lua Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。