How to handle multiple resolutions???

edited January 2015 in Android Mode

Hi! I have developed a game using Processing. Its a Box2D physics based game and it has many images. The game is running absolutely perfect on a specific resolution, say 800x480, but them problem is how can I handle multiple android resolutions?? Do I need to have multiple resources for multiple resolutions?? Or if there is a method that can automatically resize the given resources to adjust screen sizes/resolutions of android devices? I read android developer guide "http://developer.android.com/guide/practices/screens_support.html" but didn't help me. Because it says I must have multiple resources for different dpi. I have done that too but don't know how to handle them with processing? If anyone know how can I handle multiple resolutions plz do let me know as it will help me complete my project. Thanks :-)

Answers

  • Answer ✓
    • You can calculate a ratio between your original screen size and the other resolutions and use that ratio to multiply the size of all the elements on the display - a bit of a hack, but works

    • Make sure you use "floating" layout for your game, ie. no big textures that are set to that one resolution (like borders around the screen). Do everything in pieces that stretch

    • You don't need resources for all the different resolutions, you can have "normal" sized textures, like for the 800x480 resolution and then "HD" resolution for anything above 1280x800 and switch between those (good idea is to let the user switch between them, but it's tricky to implement)

    • Good rule of thumb is to keep all menus as square (and floating), that way you know for sure they will fit any resolution (read: screen aspect ratio)

  • "You can calculate a ratio between your original screen size and the other resolutions and use that ratio to multiply the size of all the elements on the display - a bit of a hack, but works" by that do you mean that I should resize the images when displaying as "image(some_pimage, x, y, some_pimage.widthratio, some_pimage.heightratio)"??? and thanks your response :)

  • Answer ✓

    Something like

    // assuming your game is landscape
    int originalWidth = 800; 
    int scaledWidth = 1280; 
    float ratio = float(scaledWidth) / float(originalWidth);
    
    image(sprite, x * ratio, y * ratio, spriteWidth * ratio, spriteHeight * ratio); 
    

    This coming from the top of my head and untested. Easiest way would be to render the whole thing using OpenGL and just quads, that way you would only need to handle the coordinates of the quads, they should (in theory) scale automagically depending on the camera angle.

    Running games on multiple devices and platforms is a tutorial of it's own and there is no one correct answer - these are just some of the things I learned while working with lots of devices and operating systems (on Unity). ^.^

Sign In or Register to comment.