Topic was automatically imported from the old Question2Answer platform.
Asked By
tncft4
Hi. I am working a mobile game project. And i don’t know to setting the width and the height.
Example:
Game width = 1000
Game height = 800
Mobile phone width = 600
Mobile phone height = 600
If I run the game on this phone, all sprites get fail. So the height and width of all scprites change.
How should I do this adjustment? Thanks…
Like Anm said, make sure to use anchored positions irregardless of screen size
Also when targeting mobile platforms its a good idea to get that device’s screen size using OS.get_real_window_size() then adjusting your game’s aspect ratio to match as there are so many different ones
Hi,
He didn’t exactly answer my question, but he gave me an idea.if I can get the size of the mobile phone, i can do the {GameSize/MobilePhone}. And I can resize all sprites this proportion.
How i get phone size? Thanks …
tncft4 | 2021-01-28 02:10
Your question didn’t really detail what “adjustment” you were expecting, so…
Set the project window size to 1280×720 in the Project Settings (or 720×1280 for a game played in portrait mode). This is a common baseline resolution for mobile, but you can also use 1920×1080 (1080×1920 in portrait) for crisper visuals at the cost of larger file sizes.
Set the stretch mode to 2d and stretch aspect to expand in the Project Settings.
Configure your UI nodes’ anchors correctly so they are moved depending on the device’s aspect ratio.
Make sure UI elements don’t touch the screen edges to avoid issues with notches and some devices’ curved borders.
Hey, I’m using this thread to learn for myself how I can get a mobile project I’m working on to scale better on my phone’s screen. But in the window settings, there is no “2d” stretch mode. Only “Disabled”, “Viewport”, and “Canvas Items”. Are one of these an equivalent to “2d”?