I am using FillViewport ( A FillViewport keeps the aspect ratio of the virtual screen size, it will always fill the whole screen which might result in parts of the viewport being cut off!)
I am trying to make my game run on multiple resolutions, when it comes to scaling world I am just using FillViewport and it works just like intended.
But when it comes to GUI, I dont know how to draw it so its always withing the screen borders ( parts of screen bein cutted off is the part of the problem here, lets say my x value for something is 0, if 0-15px is cutted of I wont see 15 pixels of my sprite)
How should I go around fixing this problem?
Related
Hi so I wanted to put 3 screenshots on 3 columns in one row like step 1,2,3 I wanted to make them all the same size. I was wondering what's the max width, height I could put before it gets stretch or compress or something (using bootstrap grid col-4). Also is there a command that helps reduce blurry picture. My pictures are a little bigger (not too big but bigger than it's suppose to be so it gets a litte blurry. so for example 300px width 300px height
What you're asking entirely depends on the pixels of your said screenshots. The smaller the pixel dimension, the smaller width and height before it starts to get too pixelated. Generally you can optimize pictures pretty neatly for web by using either Photoshop, similar or online tools.
Back in the old days (actually not that old), people used to say 72dpi/ppi (dots/pixel per inch) would be the optimal use for web, and 300dpi/ppi would be optimal for print. It honestly doesn't matter what the dpi/ppi is for web unless you are going to optimize for retina displays, in which case you'd want a better quality image than normal. You can for instance use media queries for that to check what the pixel ratio on a certain device should be before you change your pictures to a higher pixel resolution scale.
Example:
#media
(-webkit-min-device-pixel-ratio: 1.5),
(min-resolution: 144dpi){
/* Retina-specific stuff here */
}
This example along with more information about retina displays can be found here.
Normally when you're thinking webdesign / webdevelopment, you'll have a design guide / documentation, dictating the exact dimensions for x,y,z images on a certain page / pages.
My advice would be to think more about the overall memory size of the image. You can have nicely optimized images for practically any dimension at 200kb in size. Too heavy images will affect your page performance hugely in a negative way as the loading speed will be significally longer.
In my cocos2d-x game, my design resolution is 768x1024 (portrait), and I using "kResolutionShowAll" strategy (since I want to obey assets ratio). On some screen resolutions (e.g. Windows 8 PC 1920 x 1080), I have black borders on the sides.
I want to avoid these borders. My idea is to place some image as a background and to stretch it in order to fill the whole screen, and this way to avoid black borders (so, the scene should be rendered on top of that background).
My question is: how to do that? No matter how I trying to scale my background image, it always rendered within display resolution...
Thanks!
First thing first, find out the max resolution of the device family you are targeting. For example, if you are targeting Android family then the max resolution is >>> 2560x1600 (nexus series)
You can create your assets in this resolution then scale them according to different aspect ratios of devices (the scaling strategy, which in your case would be "kResolutionExactFit")
Btw, there is no harm in showing borders, several games do that. When we faced this issue, we applied the same strategy as I mentioned above(2560x1600 resolution images, with kResolutionShowAll strategy) Also, we set "setDesignResolutionSize" to "(1600, 2560)"
So, on 2560x1600 res. devices it fit well, but on 1920x1080/1280x720 devices there were borders. Please note that images that large can also result in a black screen when rendered, i.e, if a device is incapable of rendering an image(image greater than maxtexturesize of the device), cocos2dx won't render it.
In this case you can use,
CCConfiguration* conf = CCConfiguration::sharedConfiguration();
conf->getMaxTextureSize() // to check if a device is capable of rendering such image, if not you can use a lower resolution version
Or, you can also have 2 diff design resolutions.
Having said that, if you stick with "kResolutionShowAll", your game might look stretched. Just for reference, I have shared the definitions of different strategies;
kResolutionShowAll
According to the width and height of screen and design resolution to determine the scale factor, choose the smaller value of factor as the scale factor. This can make sure that all the design area can display on screen, but may leave some area black on screen.
kResolutionExactFit
Set the width ratio of the screen and design resolution as scale factor in X axis, set the height ratio of the screen and design resolution as scale factor in Y axis. This can make sure the design area cover the whole screen, but the picture maybe stretched.
kResolutionNoBorder
According to the width and height of screen and design resolution to determine the scale factor, choose the larger one as the scale factor. This can make sure that one axis can always fully display on screen, but another may scale out of the screen.
taken from,
http://www.cocos2d-x.org/wiki/Detailed_explanation_of_Cocos2d-x_Multi-resolution_adaptation
Hey everyone so this is not a duplicate! The question I have is if i make the stage width and height of my Android AIR 4.0 Application using FLASH CS6 to say 1080x1920 and make all my movieClips etc... fit the stage. Will it then be able to fit all lower screen sizes and scale automatically? instead of having to create multiple XML files and create a different size image for all available screen sizes?
I don't know a really good method of doing this, so i thought that this might be a logical approach since it's the largest possible already can't it just shrink down to all devices? I tested on my small screen and the only problem I am having is it not filling the whole width of the screen.
But then I Add this line of code in my Constructor and everything fits perfectly:
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.EXACT_FIT;
stage.displayState = StageDisplayState.FULL_SCREEN;
Any thoughts?
If you follow the Flex model, it's the other way around. Flex apps are generally built for the lowest screen density (not resolution) and scale upwards. The sizing and placements respond naturally to the screen size. At each screen density range, a new set of images are used and a new multiplier is used for all of the sizes and positions.
So let's look at it this way. In Flex, there are a set of DPI ranges. 120 (generally ignored), 160, 240, 320, 480, and 640. Every device uses a single one of those settings. Take the iPhone. You build for 160, but the iPhone is 320dpi. So all of the values you use, built for 160dpi, are doubled for your app on the iPhone. You use images twice the size, too.
For most of my apps, I have at least four different sizes (one each for 160, 240, 320, and 480 dpi ranges) of every single image in my project. The images only scale if I don't have an image for the dpi range. The goal should be to never scale any images, up or down. In each range, the images remain the same size at all times and the only thing that changes is the positioning of them.
Now, I've used Flex as my example here, since the layout engine it uses is extremely thorough and well thought out, but it is entirely possible to build a simple system for this in AS3 as well (I did it last year with relative ease).
The biggest thing you need to do is forget about screen resolution. In this day and age, especially with Android where there are hundreds of different screens in use, screen size and resolution are irrelevant. Screen density, on the other hand, is everything
I'm making a top-down game in flash, and I need to have the whole game zoomed in; the characters and scenery are really small. If I increase the height and width in flash, it messes up the image, putting pixels and strange coloration where they shouldn't be. What I am looking for is a way to change the size of the pixels, or something to that effect.
You'll 'mess up' a bitmapped image by enlarging it beyond its resolution. Two easy solutions: 1. Make your characters and scenery as vector images. Or 2. If you want them to be bitmaps (jpgs, png, whatever) create them initially at a size == the largest size you'll get to in your zoom. Then scale them down on stage to their starting scale. When you zoom in they'll look good.
I'm developing a game using libGDX framework but I have some problems trying to adapt it to different resolutions. I'll give an example of the problems I'm having.
I use Scene2D to show a simple menu. That menu have some buttons with textures loaded from a texture atlas (button textures are 9patch). In desktop, with a resolution of 800x480 the buttons look nice (even the BitmapFont) but in Android, where I use setViewport to keep the width (800px) but scale the height keeping the aspect ratio, I get pixelated images. I think that this is because my mobile higher resolution. The whole stage must be scaled to fit so the images appear pixelated.
So, my question is, what is the best way to solve this? How can I support different resolutions without end with a pixel art look?
What resolution is the android device you tested it on? You said you've used 9-patch images. This should not produce pix-elated results unless your setting them to a size and then modifying their scale(difference between screen resolution and viewport size). If you don't want any scaling you should use your screens width or height for the viewport and calculate the other one by keeping your aspect ratio. This means that you'll have to build all your object's sizes at runtime based on your new viewport.
There isn't a one way fit all solution for such problems so you'll have to find which one suits your app. You can define your button sizes as % of screen's width or height; Or set them to a fixed value and adjust the spaces between them; or a combination of both(make an object partially bigger and modify the space between them).