Programming Games for Android

Programming Games for Android 24: How to size Well Screen

42 videos

238 minutes

For you to understand how small must be what we need to happen to OrthographicCamera, I'll show you a practical example. This is the game window. Not really ... I'll put another color because I will come in handy then. This yes. When we used Scene2D, we saw that the Minijoe I had this height. This window having a size of say, 640 x 360. In some the Body had a certain height. Now what I try to do, however,

is that in the same size window, because what change is represents a Body, occupying 1 m high. That is, that 'this', measure 1 meter. How high you should measure this window? Let's put for example 4 meters. More or less, will have to be ground, enemies ... with 4 meters is sufficient. How much have to measure wide this window? Well, that's a rule of three. If we have a dimension called 640x360, 16: 9 widescreen, should remain the same

aspect ratio when we X pixels wide and 4 pixels high. They are not pixels, really! Let's call units. This can solve 3. a rule X = 640 * 4/360 This corresponds to 4 * 16/9, i.e., 7.11 meters. Actually, what you're seeing is that if I want to This window retains the same proportion as this, I must multiply my top of the window aspect ratio that want to retain. If I want to be

a window 16/9, like most phones today, I must multiply 4 * 16/9, and will remain 7.11. That is, I pass wide 7.11 to the camera, and high 7.11 4. Probably not the best number, but for what I'm going to show you now going to cost me. If I render this now ... there's the body. Need more meters high ... Of course. I said that is 10 meters high. If the screen is 4 not fit. I will multiply the dimensions of the chamber

by ... to see. Better, I'll give 32x18, which is still 16: 9 but is higher. For now 18 meters high enough for us. Yes now. We have our box falling. Why drop the box? What happens? It happens a very obvious thing, is that we have said to create the world this has to have a gravity. And obviously bodies fall, because it is affecting gravity. I need to create something that does not fall, such as a floor, as we shall see in the next episode.

To find new courses, subscribe. There will be no spam, promised :)

About the Author

foto de jotajotavm
José Javier Villena

Biography: Analyst-Programmer in different languages. Tutor PREMIUM platforms recognized worldwide as CodigoFacilito. Editor Cristalab articles. My YouTube Channel is sponsored by the ANAYA and LaTostadora publisher. I like to explain in detail and give several examples for the avoidance of doubt.