cocos2d-x 横屏下实现广告条竖立放置

(感谢cocos2d-x 的小明同学大笑

1:效果



2:实现

原理:将屏幕设置为竖屏,然后CCDirector::setDeviceOrientation()设置为cocos2d-x为横屏。

           在这种转屏模式下,控件是不会旋转的

缺点:所有Android原生控件仍然是竖立的


注意事项:

ccTouchesBegan,ccTouchesMoved, ccTouchesEnded传入的坐标值仍然是屏幕坐标。即如果有必要,需要x和y值互调一下。

2.1 修改AndroidManifest.xml

将android:screenOrientation 属性设置为:portrait

        <activity android:name=".pyramdAn"
                  android:label="@string/app_name"
                  android:screenOrientation="portrait"
                  android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
                  android:configChanges="orientation">

2.2 修改AppDelegate.cpp

bool AppDelegate::initInstance()
{
    .......
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)

		// OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp
		// the default setting is to create a fullscreen view
		// if you want to use auto-scale, please enable view->create(320,480) in main.cpp
		// if the resources under '/sdcard" or other writeable path, set it.
		// warning: the audio source should in assets/
		// cocos2d::CCFileUtils::setResourcePath("/sdcard");

		CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft);
#endif  // CC_PLATFORM_ANDROID


then, go....

只测试了Android,IOS没测试过。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值