对所有android设备的多分辨率支持 [英] multi resolution support for all android devices

查看:55
本文介绍了对所有android设备的多分辨率支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cocos2d-x将我的cocos2d iPhone游戏移植到android.我现在遇到屏幕分辨率问题:我想在游戏中使用一个高分辨率图像,所有低于给定分辨率的屏幕都应支持该图像.

我在论坛上阅读了这个不错的教程.这确实有帮助,但是我没有实现我的解决方案.有关于设计分辨率和设计资源"的比例因子的说明.资源解析.

但是,就我而言,它既可以按高度缩放比例,也可以按宽度缩放比例.不是我图像的完美缩放.有人可以为我澄清原因吗?

解决方案

在AppDeligate.cpp中,将以下行添加到

设置glview后, bool AppDelegate :: applicationDidFinishLaunching().

  CCEGLView * ev = CCEGLView :: sharedOpenGLView();ev-> setDesignResolutionSize(480,320,kResolutionShowAll); 

480、320是您为应用程序设计的分辨率.如果要使用人像,请改用320、480.如果电话长宽比与480/320长宽比不匹配,此解决方案将显示黑色边框.

I am porting my cocos2d iPhone game to android using cocos2d-x. I am now facing a problem with screen resolution: I want to use one high resolution image in my game which should be supportable by all screens lower then a given resolution.

I read this nice tutorial of multiple resolution on forum . It's really helpful, but I am not achieving my solution. There is explanation of scale-factor of resource of Design Resolution & Resource Resolution.

But, in my case, it scales either height wise or width wise. Not a perfect scaling of my image. Can someone clarify why for me?

解决方案

In AppDeligate.cpp add the following lines to

bool AppDelegate::applicationDidFinishLaunching() after the glview is set.

CCEGLView *ev = CCEGLView::sharedOpenGLView();
ev->setDesignResolutionSize(480, 320, kResolutionShowAll);

480, 320 being the resolution you designed your app for. If you want portrait use 320, 480 instead. This solution will show black borders if the phone aspect ratio doesn't match the 480/320 aspect ratio.

这篇关于对所有android设备的多分辨率支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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