• 2D
  • Problem with pixel art game on mobile version

I'm creating a game where the desktop version works normally but the mobile version has a problem with its pixels

Desktop version:

Mobile version:

Version comparison:

Settings:

Width: 480 Height: 240 Test Width: 1440 Test Heigth: 720

Mode: 2d Aspect: keep Orientation: landscape

Things I've tried and haven't worked: - use this script (https://gist.github.com/atomius0/42b5605e9f4e5b171076cd0c4453d4bb) PixelPerfectScaling.gd

  • change mode to viewport

Welcome to the forums @andrendarcie!

What node(s) are you using for showing the image in the top left corner? Does the stretching issue occur with all elements in the game, or just that image?

What I would guess is causing the issue is the aspect ratio is slightly changed by the script you are using for pixel perfect scaling, and so that is where there is a slight stretch. Looking at the code, I do not see the issue right off but I only glanced through it. If the issue is just occurring in the image in the top left corner, then it's probably a setting in the node(s) used to display the image, but if the issue occurs for the entire game, then I'd guess it's the scaling code.


This discussion was caught in the moderation queue since you have not confirmed your account yet.

Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.

(Note: You do not need to repost, the discussion has been moved out and is visible now)

If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

Thanks for the answer

  • The stretching issue occur with all elements in the game.

  • I used the script to test if it solved the problem, but I'm not using it in the game

  • I found the solution, but I don't know exactly why

I activated a property called "display/window/dpi/allow_hidpi", and now the pixels in the mobile version are perfect

@andrendarcie said: Thanks for the answer

  • The stretching issue occur with all elements in the game.

  • I used the script to test if it solved the problem, but I'm not using it in the game

  • I found the solution, but I don't know exactly why

I activated a property called "display/window/dpi/allow_hidpi", and now the pixels in the mobile version are perfect

Strange, but I'm glad you found a solution! :smile:

I thought that setting was only for desktop, but that is good to know.