今天用win32进行开发发现默认的屏幕尺寸好小而且如果屏幕上的排布非常糟糕
百度了一下
这篇文章 http://www.myexception.cn/operating-system/1436471.html
后来发现其实cocos2dx 的sample里面的hellocpp项目就有关于屏幕大小的代码
于是针对自己手机做了一些修改
AppMacros.h
#define DESIGN_RESOLUTION_640X360 3 /* If you want to switch design resolution, change next line */ #define TARGET_DESIGN_RESOLUTION_SIZE DESIGN_RESOLUTION_640X360 static cocos2d::CCSize designResolutionSize = cocos2d::CCSizeMake(640, 360);
AppDelegate.cpp
//。改变窗口大小的东西 // Set the design resolution pEGLView->setFrameSize(640,360); pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionShowAll);
要注意的地方就是setFrameSize一定要在setDesignResolutionSize之前执行,否则会整个界面乱掉
还有setDesignResolutionSize的第三个参数kResolutionShowAll也可以变成其他的值,详情见:http://www.ityran.com/archives/4809