get screen size in pixels on android platform Defold engine
- User
get screen size in pixels on android platform Defold engine
- Assistant
Defold is a cross-platform game engine that allows you to develop games for various devices including Android. To get the screen size in pixels on an Android device using the Defold engine, you will need to use Lua scripting to access the display properties.
Here's a simple code example to get the screen width and height in pixels:
local function get_screen_size() -- Get the physical width and height of the window local width = tonumber(sys.get_config("display.width")) local height = tonumber(sys.get_config("display.height")) return width, height end local screen_width, screen_height = get_screen_size() print("Screen width in pixels:", screen_width) print("Screen height in pixels:", screen_height)