Mobile Game Engine libgdx-1.2 resolution adaptive, mobile game libgdx-1.2

Source: Internet
Author: User
Tags libgdx android games

Mobile Game Engine libgdx-1.2 resolution adaptive, mobile game libgdx-1.2

Since libgdx 1.0, the stage resolution adaptive method has changed.

Let's look at the stage construction method:

public Stage (Viewport viewport) {    this(viewport, null);}

You must create your own Viewport manually.

new Stage((new ScalingViewport(Scaling.stretch, width, height, new OrthographicCamera())));

ScalingViewport: scalable Viewing Angle

Scaling. stretch: stretch by screen size

Width: screen width (the actual screen width of your game, not the screen width)

Height: screen height

OrthographicCamera: Specifies a projection camera.


Can mobile games adapt to the resolution of mobile phones ??

Mobile games should not automatically adapt to resolution due to the following reasons:

1. mobile Games Written in kjava generally have different mobile phone types on the website when you download them. Even if the same mobile phone type is different, the same mobile phone code should be generic, so the downloaded version must be different because the screen size of the mobile phone is different, and the other part of the game should be consistent.

2. from the perspective of the image resolution, if a small image changes its size (px value), the display will be distorted if it is too large. The game itself is displaying the image, but the screen size is fixed, so it should not.

However, this is not absolute. If the screen size of the mobile phone can be detected when the program is executed, and the game resources have corresponding size images, the system can automatically adapt to the situation, however, the game capacity will be too large to meet the small and exquisite features of mobile games.

Therefore, mobile games cannot automatically adapt to resolution.

Does android games also support adaptive resolution?

The xml layout is adaptive. If you play games, you have to make your own layout. If you have to make them adaptive, you can do that at the cost of losing the game processing efficiency.

Related Article

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.