如何处理银河S4的分辨率,因为它是太高了AndEngine RatioResolutionPolicy [英] How to handle Galaxy S4 resolution since it's too high for AndEngine RatioResolutionPolicy

查看:224
本文介绍了如何处理银河S4的分辨率,因为它是太高了AndEngine RatioResolutionPolicy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始与AndEngine下面这个教程:

HTTP://www.matim-dev。 COM /全游戏教程---部分1.HTML

不过这家伙看起来像它的使用低分辨率设备此测试中,我使用的Galaxy S4具有1920x1080分辨率,是啊,真他妈高。

我了解RatioResolutionPolicy的事情,但即使我在我的S4采用800x480的我2白色条纹从两侧(横向)一样,如果它是不好的调整,我需要包含另一个壁纸非常高的屏幕分辨率的设备?

此外,一些坐标,这家伙在教程中使用的都是不好的放在我的S4,我怎么做的所有设备与此相兼容?

添加code:

 私有静态诠释CAMERA_WIDTH = 800;
    私有静态诠释CAMERA_HEIGHT = 480;    @覆盖
    公共EngineOptions onCreateEngineOptions(){
        相机=新照相机(0,0,CAMERA_WIDTH,CAMERA_HEIGHT);
        EngineOptions engineOptions =新EngineOptions(真实的,ScreenOrientation.LANDSCAPE_FIXED,新RatioResolutionPolicy(CAMERA_WIDTH,CAMERA_HEIGHT),this.camera);
        engineOptions.getAudioOptions()setNeedsMusic(真).setNeedsSound(真)。
        engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);
        返回engineOptions;
    }


解决方案

您的问题不解决,但其比例。你的相机有1.66的比例,而您的设备有1.77的比例,几乎是相​​同的,但不一样的。

您需要计算比例。 Andengine将投射在相机中的任何装置,这是OpenGL和摄像机的魔法,但如果该比率是不一样的,它具有把该行,以避免要裁剪或扭曲,像图像时看到一个4: 3电影16:9电视

的解决方案是有一个具有相同的比例具有该设备的照相机,因此,如果该比率是不同的,你没有白色条纹,但例如一些额外的背景

例如,你的情况,你得到的设备尺寸,得到了比(一千〇八十分之一千九百二十= 1.7777),所以你创建一个摄像头,这个比例。即:

 浮动device_ratio = DEVICE_HEIGHT / DEVICE_WIDTH; //在这种情况下1.7777
    CAMERA_WIDTH = 800;
    CAMERA_HEIGHT = 800 / device_ratio; ///这将是450

所以,你将有一个800x450的摄像头,并可以有大小(或更大一些,你可以裁剪)的背景。这是,你不必使用图像设备的全尺寸的,而只是创建设备的同样大小的摄像头,并创建背景,在这相机看起来OK。您在800x450画布创造你的世界,并andengine将其投射在真实的设备。由于比值是一样的,一切看起来正常。没有裁剪,没有扭曲,没有多余的线条。

现在,你必须考虑更相对的方式,因为你的相机不会被永远是完全一样的,具体取决于设备。这很简单,如果你没有太多的硬codeD值。

I'm starting with AndEngine following this tutorial:

http://www.matim-dev.com/full-game-tutorial---part-1.html

But this guy looks like it's using a low resolution device for this test, I'm using a Galaxy S4 with a 1920x1080 resolution, yeah, damn high.

I know the thing about the RatioResolutionPolicy, but even though I'm using 800x480 in my S4 I got 2 white stripes from both sides (LANDSCAPE) like if it wasn't good resized, do I need to include another wallpaper for very high screen resolution devices?

Also, some coordinates that this guy used on the tutorial are bad placed on my S4, How am I supposed to make all devices compatible with this?

ADDING CODE:

    private static int CAMERA_WIDTH = 800;
    private static int CAMERA_HEIGHT = 480; 

    @Override
    public EngineOptions onCreateEngineOptions() {
        camera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
        EngineOptions engineOptions = new EngineOptions(true, ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.camera);
        engineOptions.getAudioOptions().setNeedsMusic(true).setNeedsSound(true);
        engineOptions.setWakeLockOptions(WakeLockOptions.SCREEN_ON);
        return engineOptions;
    }

解决方案

Your problem is not the resolution, but the ratio. your camera has a ratio of 1.66, while your device has a ratio of 1.77, that is almost the same, but not the same.

You Need to calculate the ratio. Andengine will project the camera in any device, that's the magic of opengl and the camera, but if the ratio is not the same, it has to put that lines to avoid the image to be cropped or distorted, like when you see a 4:3 movie in a 16:9 tv

The solution would be to have a camera that has the same ratio has the device, so if the ratio is different, you dont have white stripes, but for example some extra background.

For example, in your case, you get the device size, get the ratio (1920/1080=1.7777) so you create a camera with that ratio. ie:

    float device_ratio = DEVICE_HEIGHT/DEVICE_WIDTH;// in this case 1.7777 
    CAMERA_WIDTH = 800;
    CAMERA_HEIGHT = 800/device_ratio ; /// this will be 450

So, you will have a camera of 800x450, and you can have backgrounds of that size (or some bigger that you can crop). This is, you don't have to use images of the full size of the device, but just create a camera of the same size of the device, and create backgrounds that look ok in that camera. You create your world in that 800x450 "canvas", and andengine will project it in the real device. Since the ratio is the same, everything will look ok. nothing cropped, nothing distorted, and no extra lines.

Now you has to think in a more relative way, since your camera will not be always be exactly the same, depending on the device. This is straightforward if you don't have many hardcoded values.

这篇关于如何处理银河S4的分辨率,因为它是太高了AndEngine RatioResolutionPolicy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆