I’ve been trying to make an Android game, compatible with most screen resolutions, which doesn’t just stretch sprites and text automatically, but would rather generate them with a higher resolution (for sprites with higher pixel sprite animations and for texts - with bigger text size). The automatic GDevelop option for screen adaption seems to only stretch sprites and texts, making them blurry on higher resolution smartphones. I managed to make a simple event on start of the first scene, using the ScreenHeight() and ScreenWidth(). It works just fine in the gdevelop preview, when viewed with developer tools, but yesterday I discovered that for some reason it doesn’t work when I compile the game, installed in the smartphone itself. Does anybody have a clue why is that? I tried to find everything on the matter.
I have “No changes to the game size” in properties. Here are the events:
Maybe there’s no problem with the screen resolution but with the rendering itself.
You can try to switch the anti-aliasing in the project settings to disabled. Something with the "(good for pixel perfect games) " option. This will prevent your game assets to be smoothened which seems to be blurry in low resolution. You can also open the resources panel to individually toggle the anti-aliasing property on each asset.
In the phone, there are black areas on top and both, meaning it sticks with the original resolution - 270 / 480. I believe, that it doesn’t recognize the ScreenWidth() and ScreenHeight() functions.
My phone is 1080x2340 - pixel ratio 9/19.5
I played around a bit with the web (online) compilation - seems like the function works on smartphones, but gives less value than expected. According to it, my smartphone (with 1080 px width) is somewhere between 270 and 800. No idea why.
Maybe because the orientation is not right at the beginning?
So, do you notice any difference between using the automatic rescaling and your manual rescaling?
yes, huge, the manual text resize makes characters larger and not just stretch them, thus making them very easy to read and cool for hogher resolutions
I mean, manually, I do not rescale them, but reather render them with a higher size or in sprites - different (bigger) animations. In the events that I posted, the sprites are rescaled, but my idea for the more complex ones is to change animations
I finally thought up to just put the values of ScreenHeight and width on variables and show the values in texts. My phone (which is 1080x2340) according to these functions is 412x860.
Is that on the web export or app export?
I don’t have such an HD phone to test, but the values seem right on both my computer and my phone.
Maybe your events are conflicting? Try in an empty scene.
On the app export. On the web export they are 412 x 764 and 412 x 812 with fullscreen action. On the app they are 860. Today I read about density-independent pixels and found out that on my phone (samsung galaxy a50) they are 412 x 892 (which I can’t really explain with mine 860). I also tried the window screen function - it gives the resolution (either the base one from properties or the one I give it with the resolution action). Seems like the functions screenheight() and screenwidth() give the dp and not the real pixels of a smartphone. Now I am not sure how to get my unstretchable idea to work.
The outcomes of screenwidth() and screenheight() are not dependent on the resolution. At least they allow coding for different pixel ratios, since their ratio should be the same with the real pixels. Still I am not sure why the phone gives me 860 when it should be 892, but I’ll test a bit more.
Also, the fullscreen action doesn’t work on the app export (it is always fullscreen). I can’t get the app to cover the whole area of the phone, it sticks to 860 (and doesn’t go to the upmost top around the frontcamera).
What would happen if you were to display the game score on the part where the camera is?
That’s why you are missing 32 pixels.
So, I think I managed to do it decently, so I guess this topic is solved. The idea is that apparently the game scales up or down in pixels automatically without the properties automatic stretching options (mainly because of the concept of density-independent pixels in Android), so I just created a game with a 16:9 aspect ratio (width:1080 and height: 1920) and kept the events which detect different aspect ratios in order to add some height to the sprites and change y positions (for portrait orientation game) and change the resolution of the game to that aspect ratio. If you don’t cover some aspect ratio, it is not that bad, as on it the game will just leave some black lines. The idea is you shouldn’t worry about how much pixels to give something (a bit higher pixels is better, of course - the game looks better, but also gets bigger in memory size). I hope this topic is helpful for others GL
So were you able to make a game that scales nicely to any mobile aspect ratio??
I am making a game in portrait mode and i am looking for a solution to get rid of different aspect ratios.
I want even any tablet should also have a perfect aspect ratio of my game.
Can you kindly help me?
or if you can share your file in which you have done it. so that i can also apply it?
P.S: I need it for portrait mode game. IT WOULD BE A GREAT GREAT HELP.
GDevelop offers rescaling features which solve the black lines issue, but it’s not compatible with all games (and is not the easiest to implement…)
thank you for responding, but i know atleast this method Gruk.
i want to now what is the method(be it not easy to implement)?
Can i use anchor behaviour for every object?
If yes, please tell me how?
Yes, you need to use the anchor behavior and/or do some math magic using ScreenHeight and such, to resize/position your objects.