Add Safe Area example

Open
#146 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
lua
Domain
mobile-dev

Research direction

No file or test is named. Start by reviewing the existing examples and the Safe Area APIs described in the issue, including gui.safe_area_mode, gui.gui.set_safe_area_mode(), and window.get_safe_area(). Done means a runnable example demonstrates safe-area-aware layout on Android and iOS.

Written by the indexing model from the issue text.

Description

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.

Dominant language
Lua
Stars
130
Forks
36
Avg merge
1d 3h
Merged PRs (30d)
9

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from defold/examples

All issues in defold/examples

Similar issues

More Lua issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.