How can I change the view from portrait to landscape mode?
I want to change first view in portrait mode and the second view comes in landscape mode, I am using the gameconfig.h
file.
The code is:
//
// GameConfig.h
// Cocos2DSimpleGame
//
// Created by Ray Wenderlich on 11/21/10.
// Copyright Ray Wenderlich 2010. All rights reserved.
//
#ifndef __GAME_CONFIG_H
#define __GAME_CONFIG_H
//
// Supported Autorotations:
// None,
// UIViewController,
// CCDirector
//
#define kGameAutorotationNone 0
#define kGameAutorotationCCDirector 1
#define kGameAutorotationUIViewController 2 //2
//
// Define here the type of autorotation that you want for your game
//
#define GAME_AUTOROTATION kGameAutorotationUIViewController
#endif // __GAME_CONFIG_H
and in my appDelegate file is:
#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
#else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
//[director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
// [director setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
#endif
In the first v开发者_Python百科iew I want to show the menu in portrait mode, and also when I click on the new game then the game will show in landscape mode. I use also shouldAutoInterfaceOrientation
, but I've not found the solution.
when you want to change orientation, call this function:
[[CCDirector sharedDirector]setDeviceOrientation:kCCDeviceOrientationLandscapeLeft];
I easily Solve my problem with the help of #define kGameAutorotationUIViewController 2 view whenever I change its value to 1 the orientation is portrait mode and when I change its value the view will show in landscape mode, thnx for giving me the suggestion
精彩评论