您尚未登录

登录

您尚未登录

登录

推荐您使用PC浏览器访问

确定
  • 开发者中心
  • >
  • 云游戏
  • >
  • 快速入门
  • >
  • 横竖屏切换
  • >
  • iOS

横竖屏切换

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;
    }
}
×

本篇文章对你是否有帮助?

更多建议

请输入您的建议