故事板 - 回合制游戏的工作流程 [英] Storyboard - Workflow for turn based game

查看:269
本文介绍了故事板 - 回合制游戏的工作流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个基于回合制的游戏,并想知道我的工作流程的正确过程。目前我有以下内容:

I am creating a turn based game and would like to know the correct process for my workflow. At present I have the following:

Home View Controller(有一个 UITableView

单击第1部分中的行>使用路径1加载 UINavigationController

单击第2部分中的行>加载 UINavigationController 带路径2

Home View Controller (which has a UITableView)
Click on row from section 1 > Loads a UINavigationController with path 1
Click on row from section 2 > Loads a UINavigationController with path 2

例如:

路径1 - 轮到你玩
路径2 - 猜你的回合

As an example:
path 1 - play your turn
path 2 - guess your turn

每个路径都有大约4-5 UIViewControllers 加载到导航控制器中。

Each path has around 4-5 UIViewControllers loaded into the navigation controller.

现在我处于一旦路径2完成的阶段,用户也应该轮到他们(即路径2然后路径1)。

Now I am at the stage where once path 2 is complete the user should then play their turn too (ie take path 2 then path 1).

完成此操作的正确方法是什么?我应该从路径2中的最后一个控制器创建一个segue>通向路径1.问题是路径2有一个 UIViewController ,它有一个 UIImageView 包含大图像,它会在内存中徘徊。理想情况下,在用户启动路径1之前(在路径2完成之后)它被清除

What is the correct way to complete this? should I create a segue from the last controller in path 2 > leading to path 1. The issue is that path 2 has a UIViewController that has a UIImageView with a large image in and it would hang around in memory. Ideally it is cleared as such, before the user starts path 1 (after path 2 is complete)

推荐答案

这个答案适用于我实际上是一个更简单的方法。将ViewController引用添加到Path2的起始视图控制器。然后只需更改 UINavigationController 堆栈中的视图控制器。由于导航控制器没有子类或不需要这样工作正常。

The answer that worked for me was actually a much more simple approach. Adding a ViewController reference to the starting view controller for Path2. Then simply changing the view controllers in the UINavigationController stack. As the navigation controller is not subclassed or doesn't need to be this works fine.

- (IBAction)completeButtonPressed:(id)sender {
    NSLog(@"complete button pressed");

    Path2ViewController *path2StartVC = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"Path21VC"];

    [self.navigationController setViewControllers:[NSArray arrayWithObject:path2StartVC] animated:YES];

}

我会将一个示例项目放到github上以供参考。

I will drop a sample project onto github for reference shortly.

这篇关于故事板 - 回合制游戏的工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆