关于Cocos2dx屏幕适配

//在 bool AppDelegate::applicationDidFinishLaunching() 函数中加入

    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
	if (!glview) {
		glview = GLView::create("My Game");

		//设置分辨率
		glview->setFrameSize(480, 320);

		//code
		
		//这句必须最后,根据480,320来适配
		glview->setDesignResolutionSize(480, 320, kResolutionShowAll);

		director->setOpenGLView(glview);
	}
 1 enum ResolutionPolicy
 2 {
 3     // The entire application is visible in the specified area without trying to preserve the original aspect ratio.
 4     // Distortion can occur, and the application may appear stretched or compressed.
 5     kResolutionExactFit,
 6     // The entire application fills the specified area, without distortion but possibly with some cropping,
 7     // while maintaining the original aspect ratio of the application.
 8     kResolutionNoBorder,
 9     // The entire application is visible in the specified area without distortion while maintaining the original
10     // aspect ratio of the application. Borders can appear on two sides of the application.
11     kResolutionShowAll,
12 
13     kResolutionUnKnown,
14 };

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值