how to track in Lua script switching between portrait and landscape on android platform?…
- User
how to track in Lua script switching between portrait and landscape on android platform? Defold engine
- Assistant
To track orientation changes (switching between portrait and landscape mode) on an Android device using Defold Engine, you generally have to rely on the window.set_listener() function to detect changes in window properties, which include width and height. Defold currently doesn't have a specific callback for orientation changes, but you can infer the orientation by comparing the width and height of the window.
- User
event == window.WINDOW_EVENT_RESIZED always false
- Assistant
- User
do you know about defos?
- Assistant
Yes, DefOS is a community-created Defold native extension that provides additional operating system functionality that is not available in the core Defold engine. It adds features for manipulating the game window, like resizing, changing the title, toggling fullscreen mode, and handling window focus, among others.
Regarding the monitoring of orientation changes on mobile devices, DefOS does not provide direct support for detecting orientation changes. It is more focused on desktop operating system functions rather than mobile-specific features like orientation.
To handle orientation changes in Defold for mobile platforms, you generally have to work with the built-in functionality provided by the engine and potentially extend it with your own native extension if necessary. As described previously, periodically checking the dimensions of the window and comparing them to the previous state within your Lua script is a workaround for orientation detection but may not be as efficient or robust as a native event-based solution.
- User
give me window.WINDOW_EVENT_RESIZED analogue in defos
- Assistant
DefOS does not bring an event-based API into Lua for window resize or device orientation changes as of my last update. Its functionality is more about giving you control over the window properties and other OS-specific features.