37

What you want is to constrain the camera viewport on portrait or landscape(depending on your needs), by computing camera.orthographicSize property, so you can build your 2d scene regardless of aspect ratio and resolution: // Attach this script on your main ortohgraphic camera: /* The MIT License (MIT) Copyright (c) 2014, Marcel Căşvan Permission is ...


15

It's easy: Fonts do not need to match resolution, they need to match pixel density. Pixel density is measured as pixels per inch(PPI), or pixels per centimeter. There's also a measure unit called density independent pixels(DP). It is defined that 1dp is the size one pixel has on a 160 PPI screen. Now coming back to fonts, try to make this test: put your ...


14

You seem to want to keep the same textsize/screensize ratio. Basically what you do is develop at one resolution and let that be scale 1.0. Then you divide the new screen width by the old width and that is your scale factor. For example. Developing on 2560x1440 with font size 16 and running on 1920x1080. Font size will be: 1920 * 16 / 2560 = 12 I do the ...


14

In fact, the original question is 1 cast away from the solution. Original Code glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60, window.width/window.height, 0.01f, 100.0f) Fixed Code glMatrixMode(GL_PROJECTION) glLoadIdentity() gluPerspective(60, (float)window.width/window.height, 0.01f, 100.0f) The problem was that window.width and window....


10

To understand what's going on, you have to understand the rendering pipeline: Your geometry (the quad) is initially defined in world space, think of this as some global coordinate system. Inside of the vertex shader those are transformed to normalised device coordinates (NDC), a virtual coordinate system defined so, that everything from -1 to 1 will get ...


5

You typically don't need different sizes of assets - imported textures and sprites with automatically-generated mip maps will look nice when rendered at any size less than or equal to the original pixel size of the image. The scene layout is the challenge. One good approach is as follows (and FYI I use a 3D camera looking at 2D content positioned at z=0): ...


5

I believe what you're asking is how to get rid of letterboxing, like this: By default, AndEngine assumes you want some fixed aspect ratio. It then uses letterboxing to handle devices with different display aspect ratios then what you're providing. The advantage is you have certainty about your layout. There's more than one approach to get rid of them, ...


4

Depending on what function you call, you can probably resize the image correspondingly to diffrent resolution. This is a common problem, and is often solved with dynamic screen scalings. To just take this problem one step futher, you need to do dynamic correction with your GUI to maintaint the correct layout over all possible screens. and assuming you are ...


4

I see that you've already accepted an answer, but I feel I can add to it. I have written a blog post about this here. The gist of it is as follows: "After a bit of research, I’ve come to the conclusion that most Android phones that I want to target have a 480×800-ish resolution. I’ve also noted that the smallest aspect ratio of any Android phone (held in ...


4

It's a fair approach, I've seen not-so-simple games using it. However, as your target is high quality, I advise you to support all aspect ratios properly. You don't want your players annoyed because you're using only a percentage of their pixels. So you've got two options: If you only have a few aspect ratios to support (e.g only 4:3 and 16:9), you can ...


4

For desktop games you can control the supported aspect ratios directly in Edit -> Project Settings -> Player -> Resolution and Presentation But for mobile, or situations where your aspect ratio might change during play (eg. resizing a window dynamically), or you want to use letterboxing for artistic effect, we'll need an in-game solution. You ...


4

First, attach a Canvas Scaler component to the GameObject with your Canvas on it. Set it to Scale With Screen Size. Set the resolution you want your game to mimic. I have 640x1136 set. Set Screen Match Mode to Expand. Inside this GameObject, create a new one. In my scene, it's called "GameSizingPanel". You can see it just has a CanvasRenderer and an Aspect ...


3

xoffset = (targetScreenWidth - image1Width)/2;


3

The fourth option is to generate the image when you know the resolution (after startup). This means having enough information in the game to properly render the image to texture on startup (and maybe caching it for future play sessions). This needs to be debugged carefully to ensure all resolutions come out correctly. But for things like text it's just ...


3

This depends on how you've authored the objects. 3D objects and 2D sprites positioned in your scene's worldspace will not move, scale or change their worldspace transformations no matter what happens to the display screen/window. BUT: These objects are viewed through a Camera, and the camera's view is mapped to the screen. That mapping will change as the ...


2

To answer the question: yes, it is a good idea to make a game for a given aspect ratio and screen resolution. However, it is only a good idea in certain circumstances. Those circumstances include, but are not limited to: developing for a platform with a particular aspect ratio and screen resolution like a console where display hardware is fixed (which it ...


2

In your main activity, you can call: DisplayMetrics displayMetrics = new DisplayMetrics(); this.getWindowManager().getDefaultDisplay().getMetrics(displayMetrics); displayMetrics will then give you a bunch of data, for example: displayMetrics.density; displayMetrics.densityDpi; displayMetrics.heightPixels; And so forth. In the comments ...


2

Separate your screen coordinates from your world coordinates. Pick a coordinates system that will accurately represent your position with enough detail. For example, if you're using a 256x144 int coordinate system for your positions, you only have 144 different positions available to you, even when the screen size can display 1080. You may want to use a ...


2

Pretty simple, there are two candidate solutions, one where the full width is used and one where the full height is used, you must always pick the smaller of those: widthToUse = Math.min(screenWidth, screenHeight * ratio) heightToUse = Math.min(screenHeight, screenWidth / ratio) offsetX = (screenWidth - widthToUse) / 2 offsetY = (screenHeight - heightToUse) ...


2

By quickly looking at the algorithm it seems more suited to image/video processing. The problem with such image processing based techniques is that they are highly analytical, and they are more likely to leave some artifacts that might not be suitable for games due to the dynamic nature of the games, unlike movies or images were the data is previously known....


2

Don,t do any thing just set the scale of the font and it will work for all type of device font.setScale( .9f,.9f);


2

I found the solution for this from the Cocos2d-x forums. The following code is needed in the didFinishLaunching method: // Set RootViewController to window NSString *reqSysVer = @"6.0"; NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) { [window ...


2

You forgot to quote the important part of FN-U2 for your question (emphasis mine): App uses the whole screen in both orientations and does not letterbox to account for orientation changes. Minor letterboxing to compensate for small variations in screen geometry is acceptable. What you're doing here is perfectly fine, since it indeed can be ...


2

If you come around to using the bars it's actually pretty simple to implement (I'm posting this even though the OP stated the opinion of it being unacceptable because it has the benefit of being not near as bad on mobile and it's a simple solution that requires no code whatsoever) Camera.orthographicSize is a variable within the ortho camera (which most 2D ...


2

You've covered the basic ideas in your question. Which method you use depends on your requirements. You might use a combination of approaches. 1. Make the image 320x240 and scale it up on the larger resolution (will look pixelated) Do this if you don't need higher detail and just need to show the image larger. Good for low detail images like old-style ...


2

These are all of the aspect ratios you have to handle: 4:3 3:2 8:5 5:3 16:9 Source: https://stackoverflow.com/questions/7199492/what-are-the-aspect-ratios-for-all-android-phone-and-tablet-devices Create 5 sets of graphics or use an engine like LibGDX and it's https://github.com/libgdx/libgdx/wiki/Viewports @Edit When creating a LibGDX app, you can set ...


2

As Uri Popov notes in the comment above, this is done via the Game window rather than the Scene window itself. Just beside the display selector at the top of the Game window, you'll see a drop-down menu that lets you select different aspect ratios or fixed resolutions. By clicking on the "+" at the bottom of the menu, you can add your own custom versions. ...


1

I'm doing this in a game I am currently working on. I have a background image that is 1140x720. The most important bits (the ones that should never get cropped) are contained in the 960x640 middle area. I run this code on the start function of my camera: float aspect = (float)Screen.width / (float)Screen.height; if (aspect < 1.5f) Camera....


1

Try using the android:screenOrientation="landscape" option in the manifest file's activity tag.


1

What your dealing with is an aspect ratio mismatch. Your trying to map an aspect ratio of 1 to an aspect ratio of 16:9 or 16 :10. That is why your tiles look stretched. Set your games resolution to a square aspect ratio like 300x300 if windowed. Or make your tiles about 160x90 pixels to look square at that resolution. Topics of interest would be http://en.m....


Only top voted, non community-wiki answers of a minimum length are eligible