横竖屏切换
iOS SDK 提供动态切换横竖屏游戏画面功能。客户端通过 SDK 提供的接口,传入指定游戏横竖屏标识参数。
在申请游戏的时候 UIViewController 传入 orientaion 字段,可以控制游戏画面横竖屏显示
设置横屏
// 申请游戏
- (IBAction) start:(id)sender {
NSDictionary *game = [self.gameList objectAtIndex:self.tableView.indexPathForSelectedRow.row];
// 设置横屏
orientation = HMCloudCorePlayerOrientationLandscape;
NSDictionary *gameOptions = @{CloudGameOptionKeyId:[game objectForKey:@"id"],
CloudGameOptionKeyOrientation:@(orientation),
CloudGameOptionKeyUserId:DEMO_USERID,
CloudGameOptionKeyUserToken:DEMO_USERID,
CloudGameOptionKeyConfigInfo:@"config",
CloudGameOptionKeyCToken:[self generateCToken:[game objectForKey:@"id"]],
CloudGameOptionKeyPriority:@(0),
CloudGameOptionKeyPlayingTime:@(DEMO_GAME_TIME*1000),
CloudGameOptionKeyExtraId:@"",
CloudGameOptionKeyArchive:@(0),
CloudGameOptionKeyProtoData:@"",
CloudGameOptionKeyAppChannel:[game objectForKey:@"appChannel"]
};
NSLog(@"startSDK params : %@", gameOptions);
self.gameVC = [[HMCloudPlayer sharedCloudPlayer] prepare:gameOptions];
if (!self.gameVC) {
NSLog(@"startSDK Failed .");
return;
}
}
设置竖屏
// 申请游戏
- (IBAction) start:(id)sender {
NSDictionary *game = [self.gameList objectAtIndex:self.tableView.indexPathForSelectedRow.row];
// 设置竖屏
orientation = HMCloudCorePlayerOrientationPortrait;
NSDictionary *gameOptions = @{CloudGameOptionKeyId:[game objectForKey:@"id"],
CloudGameOptionKeyOrientation:@(orientation),
CloudGameOptionKeyUserId:DEMO_USERID,
CloudGameOptionKeyUserToken:DEMO_USERID,
CloudGameOptionKeyConfigInfo:@"config",
CloudGameOptionKeyCToken:[self generateCToken:[game objectForKey:@"id"]],
CloudGameOptionKeyPriority:@(0),
CloudGameOptionKeyPlayingTime:@(DEMO_GAME_TIME*1000),
CloudGameOptionKeyExtraId:@"",
CloudGameOptionKeyArchive:@(0),
CloudGameOptionKeyProtoData:@"",
CloudGameOptionKeyAppChannel:[game objectForKey:@"appChannel"]
};
NSLog(@"startSDK params : %@", gameOptions);
self.gameVC = [[HMCloudPlayer sharedCloudPlayer] prepare:gameOptions];
if (!self.gameVC) {
NSLog(@"startSDK Failed .");
return;
}
}