We also discuss the issue of resolution self-adaptation in smartphone game development.

Source: Internet
Author: User

Currently, the variety of smartphones on the market is vast, and their resolutions vary widely. When developing mobile games, it is inevitable that you will encounter problems of automatic resolution adaptation. A cross-platform mobile game engine I developed some time ago naturally encountered this problem. The engine is named ogl2d. Users can easily develop and debug games in windows, and compile the engine to Android and iOS operating systems. When setting design goals, we require them to automatically adapt to the current mainstream resolutions, such as 240x320,320x480,480x800,480x854,640x960,768x1024,800x1280. The following is my experience on this issue.

Question proposal

In the face of this problem, the lazy developer will not hesitate to say that I only support the most basic resolution. Let's hand over the rest to the operating system for processing, for example, Android and iOS only support 320x480, and the system automatically scales at runtime. As a result, new problems have emerged. for users who have bought high-performance mobile phones, the pictures they see are always vague and even contain sertices, this is intolerable for a game with high quality requirements. It can be imagined that if an iPad user sees a 2.5 x screen that is times larger than the X screen, he or she will say: My Day, is my pad broken or my eyes wrong!

Key Points of issue decomposition and discussion

The analysis shows that this problem can be divided into several subproblems:

1. How to view Fine images for different resolutions;

2. How to correctly control the layout of the interface on the screen with different aspect ratios;

3. How to easily expand resolution support.

I am not going to describe in detail how to make the game program use the actual screen resolution and obtain the current resolution. You can learn this in books related to Android and IOS; of course, the discussion here does not involve basic knowledge such as how to load images, how to draw vectors, and how to access file IO streams. You can find a lot of sample code on Google or Baidu. The following discussions are entirely about some strategic suggestions that are not necessarily optimized. They may have such limitations, but believe that these strategies are at least feasible and reasonable.

First, let's take a look at how to see fine-grained images for different resolutions?

The answer to this question is too simple. You only need to configure the corresponding images for some mainstream resolutions, which is the most direct and effective. Of course, you also need to note that these images with different resolutions are placed in the response directory. For example, if we use pixels on the short side of the screen as part of the resource directory path, the ogl2d Resource Directory contains 240 (representing the 320,480x20 Resolution, and so on ,..., 800 and other sub-directories. All the images have been scaled to a reasonable size for their respective resolutions. Wait. What is the proper size you mean? I mean, scale the image to a multiple that is equal to the shorter side of each resolution based on the ratio of the shorter side of each resolution. For example, a button is 800 x pixels at a resolution, naturally, the size at the resolution of 320 should be 30x30 pixels, which is one out of eight points on the short side of the screen. The reasonable size also implies such a requirement that the sizes at different resolutions should be integers to avoid severe sawtooth.

240:

320:

480:

...

...

800:

Secondly, how can I correctly control the layout of the interface on screens with different aspect ratios?

From the above analysis, we can get an important prompt that the layout should not depend on the screen resolution and aspect ratio. What I have adopted is to define a basic unit, the positioning of all screen elements is based on this unit, and the unit I select is the width of a standard button. On mobile phones, most mobile phone screens are not large. In order to be more user-friendly, buttons cannot be too small. I chose 1/8 or 1/10 of the short side of the screen. With this unit length, the layout is simple. All screen elements are arranged at the same position as the four corners of the screen or the standard distance from the center at different resolutions, for example, the pause button in the game is arranged at a distance of 1.5 standard length from the upper right corner of the screen. The pixel value at the specific position is not important. You can calculate the pixel value at the runtime, because the resolution is not changed when you play a mobile game (haha, when writing a Windows game, some of the issues that need to be paid attention to do not seem to be a problem on the mobile phone ).

Finally, how can we easily expand resolution support?

This is of course a policy problem. The expanded resolution support here refers to enabling the program to support new resolutions only by adding the content of the resource package without modifying the program. The policy I selected is to list the resolution directories under the Resource Directory when the program is running, and compare the pre-supported resolutions one by one, which is the closest to the current resolution, of course, in most cases, one of them will be matched directly. In addition, some mobile phones have very special screen resolutions, and there is no problem. You only need to remove the short side from the shorter side that is the closest to the one that supports resolution to get a scaling ratio, when drawing and positioning (if you are using OpenGL, One alternative is to adjust the observer's perspective and focal length), use this ratio for scaling. Of course, there will also be fuzzy and sawtooth, however, because the selected scaling resource is very close to the target size, such distortion can be controlled within a certain range.

The above is my experience in writing the cross-platform game engine "ogl2d", which is not mature, let alone the principle. It is just my strategy and solution for reference by a single friend. So what is the final effect of this engine? The following is a small casual action game developed by Alibaba Cloud. It is still being updated and updated, transplanted to an android game we developed two years ago with the same name.

This is the latest somatosensory action game "God of Wealth 2", which can run on various versions of iPhone, iPad and iPod Touch. Android development has also been completed and will be launched in due time. I believe many of my friends like Xu guanjie's classic song "God of Wealth". This is a brand new mobile game with the same name. With the music of God of Wealth, in the Spring dynasty, on the path of the mountains, in the colorful fireworks, chase the footsteps of God of Wealth and receive the blessings of God of Wealth! God of Wealth has arrived in the world. Do not miss it!
Official Address:
Http://www.otlive.cn/html/mobile/app/FortuneKing2/iphone_cn.shtml
IOS version:
Http://itunes.apple.com/cn/app/fortune-king-2/id496183122? L = ZH & LS = 1 & mt = 8
English: http://itunes.apple.com/app/id496183122? Mt = 8

Enter the game and immediately immerse yourself in a cheerful and festive atmosphere, deep background, fireworks, dynamic music, and bring you to the blessing of God of Wealth. This game is already in the 2nd generation. It retains the main line of the 1 generation game, facilitating operations and adding new models. both art and special effects have made a qualitative leap.

Before entering the game, you can click the Avatar on the left of the screen to switch to the game's main character. There is a real story here. It is said that during the development, an employee of the production company installed it on his wife's mobile phone, and her colleagues immediately liked the game, however, I asked the same question: why is it true that a boy is always running around in the game? As a result, the game has the role selection function.
The game has three modes available:

Normal Mode: it is also the growth mode. players drag the child or tilt the mobile phone to control the left and right movements of the child, to catch the treasures spread by God of Wealth. The more the child receives, the higher the score, and the more child receives in a row, the score is higher. When a certain number of treasures are caught without missing too much, the pass is also based on the reward scores played by players in this Council. The green bars in the lower-left corner of the screen represent the progress of the completion of this function, and the red bars in the lower-right corner of the screen represent the leakage of treasures. Different treasures have different scores, and there are two special treasures: After receiving the Dragon Ball, the score will be eliminated in full screen, and the boy who receives the peach will become larger. The game is in progress, and there is another opportunity to start the fairy flowers. When you see the fairy floating in the air, click the upper half of the screen, and the treasures will pour down.

Time-limited mode: catch more treasures within the specified time. With the passage of time, the whereabouts of treasures may get faster and faster, which is extremely challenging.

Bird mode: An infinite pattern that continues until a certain number of treasures are leaked. Of course, as the number of leaks increases, the game will be more intense and exciting, fully challenging your limits.

The game integrates the gamecenter and jiucheng game communities to see who is lucky.

In the traditional Chinese culture, every spring festival, family members are decorated with lights to receive new blessings and welcome the God of Wealth to pray for a good harvest of wealth in the coming year. On the eve of the New Year, God of Wealth 2 was unveiled! In the game, you are a fortune boy. You can simply move around to receive wealth and good luck from God of Wealth. God of Wealth 2 integrates the traditional Chinese culture into a fashionable action game, from sound effects to Operation styles, from interface colors to game elements. Every detail is ingenious, let the players in the celebration please God of Wealth! Financial resources are rolling down from the sky, receiving more, and prosperous fortune!

"God of Wealth to 2" developed by Chengdu origin Technology Co., Ltd. (www.otlive.cn), good fortune from "God of Wealth to 2!
★Company Website: http://www.otlive.cn
★Official blog: http://blog.sina.com.cn/otlive
★Official Weibo: http://weibo.com/ottec

God of Wealth 2 can run on a variety of mainstream devices. The screen is exquisite and dynamic:
★IPhone
★IPod Touch
★IPad

God of Wealth 2 provides a friendly control experience. You can switch between the following methods:
★Gravity sensing
★Touch control

Fortune 2 provides three different game modes:
★Classic Mode
★Time-limited Mode
★Bird mode

Fortune 2 integrates multiple community interaction experiences. You can choose your preferred game interaction community to interact with netizens:
★9 City game center (the9)
★Game Center)

<Fortune King 2> description

In traditional Chinese culture, in the annual occasion of Chinese New Year, every household being decorated, celebrating the Spring Festival and enjoy a life of Hangzhou and comfort. celebrating the fortune king, praying for a good harvest and good fortune for the coming year. in the New Year approaching, "Fortune King 2" released fortunately! You are a money dispenser in this game, you can get the wealth and good fortune spreaded by the fortune king, by moving around und simply. "Fortune King 2" put the traditional Chinese culture into the fashion action game, And from the sound settings to the operating style, from color interface to the game elements, every detail is unique, allowing the player to greet the fortune King arrival in highly Celebrating. Continuous treasure fall from the sky, catch more, better fortune!

"Fortune King 2" action game develop by chengddu origin Technology Co., Ltd (www.otlive.cn), and good fortune from the beginning of "Fortune King 2 "!
★Web: http://www.otlive.cn
★Official blog: http://blog.sina.com.cn/otlive
★Official microblogging: http://weibo.com/ottec

"Fortune King 2" can be run on a variety of major divices and exquisite picture and dynamic full:
★IPhone
★IPod Touch
★IPad

"Fortune King 2" provides friendly control experience, you can switch any control way as you pleases anytime:
★Gravity control
★Touch control

"Fortune King 2" provides three different game modes:
★Classic Mode
★Time limit Mode
★Bird mode

"Fortune King 2" integrates multiple community interaction experience, you can choose a SNS which you like, to interact with the players:
★The9
★Game Center

 

Author: Wang Feng www.otlive.cn

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.