I'm doing a mobile game in Unity for Android and iOS, I already have my assets design for a device of 480*800 pixels, but when I launch my game in a biggest screen, the image is horrible.
I tried different technics to scale the camera, the images... without success. In Android there is multiple size of drawables : hdpi, xxdpi... and in iOS the images can't be the same for an iPad and an iPhone, so I did not understand, how I can load multiple images to fit all the screen resolution.
or How to make my assets to do that. Can you explain me please ?
400 pixels is incredibly small for game images these days. We rarely get or use anything less than 4K these days.
One thing: if it is actual "pixel art" (so, "retro" pixel art), you must use the "point" enlarger to keep the "pixel shape" when you enlarge it.
Note that pretty much everyone uses 2DToolkit with Unity for 2D projects. It creates sprite sheets for you. BUT it also has the concept of different sprite sheet sets for different screen sizes, if you are working on a pixel-perfect concept (as much as that has any meaning today).
Unity itself does not contain any "different sprites for different devices" concept, and this is one of the main reasons 2DToolkit remains so popular.
Finally note that: if you make computer games it is
...extremely difficult...
dealing with different screen ratios.
Say you are making a side scroller: what does it "mean" that some players have a wider screen than others? What should you "see" on a wide screen versus a normal screen in, say, GTA?
This can involve a huge amount of conceptual work and programming. This affects everyone who makes games, from the kid on the corner to Nintendo. There is no "simple solution".
Related
I want to get into mobile game development but before I get started I want an idea of what the process is like so I can choose the right tools.
Obviously screen resolution is the most obvious, but what other things have to be changed so it will work on multiple phones?
This is an enormous topic. The most basic design is to have a rectangular play area that can be stretched to fit the screen you are using. Whether you keep your original aspect ratio or "match_parent" for both dimensions is up to you.
You've recognized that that won't take full advantage of screens of different resolutions so many courses and tutorials will walk you through learning to design a relative layout that will arrange and size some elements according to the available space and other elements according to how much space the content needs. You'll also eventually provide images of different resolutions that will be used for different screen densities.
I recommend you jump right into game development before understanding this topic fully. There are many intricacies that you'll come to understand as you work with them.
I'm currently building an application for Android (a game). So far, I've created assets for all devices, from ldpi all the way up to xhdpi. I'm building the application for Android 2.2 and above.
Should I stop producing ldpi images?
It would cut down the time it takes to produce the graphics fairly significantly. On top of this, I don't think that very many devices (commonly used) these days actually fall into the ldpi category.
Thoughts?
There are only 3.1% of phones with ldpi screens (as of 1st Jan 2016). Here is the statistics about devices and their screens. You can decide whether to support them or not.
True, but to build your brand image, you have to do the job perfectly, for everyone. Even if there are a few tens of users who use low dpi, it's totally worth it. :-)
You could if you like. you could set a in code aspect ratio resizer, and size all the images accordingly when loading them. So no matter what screen you play on, they take up the same percentage of it. This significantly cut down graphic time, and looks great.
another way you could do it, is get Paint.net and simply build the largest graphics first. Then go into Image and Resize, and set the resize to by the ratio difference, say 75%. save this and you are done. Should cut the entire time down significantly as well, and also looks great.
I have done it both ways, and you cant tell the difference.
I have always built my code so that it fits the game to the screen.
for example in a sidescrolling fighter if a character is 5/8 the screens height, and 3/12 the screen width on my testing device, and it looks great>>> you can do a little math, figure out the h/w ratio of the screen any user is playing on, and adjust the image at load time so that no matter the device your image will take up the percentage of the screen you intended it to.
It is suitable to use all image packs, because if most devices support MDPI, but you would be losing market devices with low resolution. Use LDPI.
i am NOT an android developer and im trying to understand what they need in terms of graphical resources to make an app that functions across many android devices.
i have (tried to) read this page http://developer.android.com/guide/practices/screens_support.html , but find it somewhat bewildering. they talk as if screen density is the important thing "Supply alternative bitmap drawables for different screen densities" but then, if you dont know the size of the screen, you cant really think in terms of layout. is the idea to make buttons and logos that are the same size on all screens with the same density, such that on a large screen there is just a bunch of space, and on the small screen its all packed in tight? i dont understand how just thinking in pixel density gets me any closer to knowing what to provide.
are you supposed to create resources for every screen size AND pixel density? say it aint so.
anyway can somebody tell me... if you were developing an app what do you need for graphics? is it possible to provide graphics that are large and just let them scale down? is it inevitable that the devloper will have to mess with the graphics himself anyway? or can he be provided with sets of png files of certain sizes that will be ready to use?
thanks!
Here's what we do at my work place. Suppose we get a desing for the app. We make our designer create 3 psds versions for the same desing. the 3 psd's are for the 3 ranges of desnity. The size used for the psd are
240*320 (Low Density)
320*480 (Medium Density)
480*800 (High Density)
Most of the time when I write layouts, I use wrap_content which means a view must take the size of the content it wraps. Which works most of the time as I have a density specific version of the design so the image i use as background should be suitable. The thing to note is that, in android you can can put the 3 sizes of the same image in different folders such as drawable/ldpi, drawable/hdpi.
Eg: you have a bg.png and have a version for large phones and a version for small phones. You put the big bg.png into hdpi folder and the small png in the ldpi folder. Android will automatically select the appropriate image based on the phone density. But you need to make sure the file name is the same.
There are cases where you need to resize you background images without makeing the image looking too scaled. For this android uses the draw9patch tool. With this tool you can specify areas which can scale and areas that shouldn't scale.
9 Patch png's are your friend. Read up on them here:
http://developer.android.com/guide/topics/resources/drawable-resource.html#NinePatch
and here:
http://developer.android.com/guide/developing/tools/draw9patch.html
Those are your best bet for any kind of graphic that will stretch nicely (i.e. not gradients, they will come out slightly pixelated on some screens probably) The power of these types of images is that you can tell the system which pixels to repeat if it needs to stretch the graphic. This means that stretching can be done without loss of image quality (again depending on your image and how you choose to make the nine patch. The "show bad patches" button in the draw9patch program will show you potential problems. Hint: keep your repeatable pixels down to 1 on left and 1 on top and you'll have no problems with bad patches) Any graphics that can be made in to 9 patches will only need 1 size since the system can effectively make it whatever size it needs.
are you supposed to create resources for every screen size AND pixel density?
You may if you like. This would ensure that the application will look great across all devices. I understand that this is not feasible for all projects though. In general if you make separate resources for the different densities you'll get something that looks acceptable on most of the devices out there. All of the devices are classified as ldpi, mdpi, or hdpi (there may be an "extra high" level now too, I am not certain off the top of my head) So if you supply graphics for those 3 densities then the system will know where the device falls under and will pull the correct graphics.
is it possible to provide graphics that are large and just let them scale down?
Yes the system will scale down your graphics if needbe. But be aware there are consequences with this approach. First every time the system hast to scale a graphic up or down it is going to taking up CPU and memory to do so. This may not be an issue if you have relatively few things to scale, but if you have many it could cause noticeable lag time during on the lower power phones. Second, To my knowledge all of the graphics in android are raster, which means if you are letting the system scale something up or down image quality is going to decrease some. Again depending on the specific images this may be more or less noticeable on the actually device at runtime.
My best advice is supply them with resources of a few different sizes and run the app on as many different devices as you can. Once you see how your different resources look on the devices of different sizes you'll have a much better feel for which ones you need to supply to get the UI looking as consistent as possible across the largest swath of screen sizes and densities.
I have a client that gave me a .psd file that contains the entire screen of an Activity with all the graphics. The resolution is 480x800. The client wants the application to look identical to the one in the .psd file. The problem is that different devices have different resolutions and sizes. I know that the density is what really matters but how can I scale the graphics to look the same on all the devices? For example, I exported all the layers and recreated the screen in Android but, for some reason, the screen looks more crowded on a Nexus One (480x800).
One idea would be to create 9 patch images from the graphics and use for ImageViews android:background instead of android:src right?
Isn't it better to have a 320x480 resolution for the graphics? Or do I need for both resolutions? Also, I have to consider the height of the status bar which I understood it is 25dip but I am not certain about this.
So, to summarize, I am interested to find out what is the best way for a client to give you the mockups and graphics so that it is easy for the developer to implement according to the specifications.
That's something that's not easy to solve. Think of a webdesigner, one can't know all the possible resolutions and settings of every browser so he has to scale things accordingly.
In my opinion there are only three approaches here.
First: Let him state what devices he wants to support and only support those devices. Extract the layers with the size of the device with the highest resolution and scale them down on other devices.
E.g. If you have to support two devices with 480x800(2) and 240x300(1), export all images to be 480x800 and scale them down accordingly. Don't write a single application for every device.
Second: Export the graphics with the highest resolution possible and scale them down on all devices relative to the device being used. Imagine, again, a webdesigner. All he does is define margins, paddings, etc. and it will look nice in almost any browser. You should do the same and resize your elements on demand.
Third: Make the application fixed, e.g. define a size of 200x200 for your whole application and just fill everything larger than the screen with a certain color, e.g. black. This happens a lot with java ME applications, they look great on the hardware they were made for and are still playable on hardware that is beyond their time though they look pretty ugly.
Hope this helps,
Robin.
I've determined an estimate of the size of my Android emulator's screen in pixels, although I think its resolution can be changed to other numbers. Quite frankly though that doesn't eliminate the general problem of not knowing how many pixels on each axis I have to work with on my Android applications in general.
The main problem I'm trying to solve is this: How do I make sure I don't use a faulty resolution on Android applications if I want to keep things' sizes constant (so that if the application screen shrinks, for instances, objects will still show up just as big - there just won't be as many of them being shown) if I wish to do this with a single universal resolution for each program? Failing that, how do I make sure everything's alright if I try to do everything the same way with maybe a few different pre-set resolutions?
Mainly it seems like a relevant question that must be answered before I can come across a complete answer for the general problem is how big can I always make my application in pixels, NOT regarding if and when a user resizes the application's screen to something smaller than the maximum size permitted by the phone and its operating system.
I really want to try to keep this simple. If I were doing this for a modern desktop, for instance, I know that if I design the application with a 800x600 canvas, the user can still shrink the application to the point they're not doing themselves any favors, but at least I can basically count on it working right and not being too big for the monitor or something. Is there such a magic resolution for Android, assuming that I'm designing for API levels 3+ (Android 1.5+)?
Thanks
Hmm, I suggest you read this: Supporting Multiple Screens. That gives a wealth of information on how to handle different screen sizes. In particular, read about its concept of density independent pixels versus absolute pixels. Density independent pixels are essentially pixel sizes that the system automatically scales for you depending on the screen size you're working on. It considers the 'standard' screen as that of the G1, Hero or similar devices, i.e. 480x320 pixels with a density of 160dpi. If the screen you're working with is bigger than that, i.e. the Droid or Nexus One, it adjusts all density independent pixel sizes by 50%.
Alternatively, if you're really talking about canvases, as in, Canvas for animations etc, you can just call canvas.getWidth() and canvas.getHeight().