在xcode中使用presentModalViewController切换视图时检索分数
我面临着在某人完成游戏后检索游戏“高分”的问题。
我所做的是:
当时间达到 0 时,我调用 PresentModalViewController 方法。
GameEndingViewController *gameEndingView = [[GameEndingViewController alloc] initWithNibName:@"GameEndingViewController" bundle:nil];
gameEndingView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:gameEndingView animated:YES];
[gameEndingView release];
我想显示我在这个 gameEndingView 的主游戏循环中获得的分数。然而,似乎当我使用presentModalViewController方法来切换视图时。我在游戏循环期间更新的变量分数被重置。我的整个游戏循环都在视图 gameMainView 中。
有人可以向我解释一下presentModalViewController的使用以及我应该如何更好地解决我的问题吗?
非常感谢。
I face this problem of retrieving a game "highscore" after someone finishes a game.
What I did was this:
I call presentModalViewController method when time reaches 0.
GameEndingViewController *gameEndingView = [[GameEndingViewController alloc] initWithNibName:@"GameEndingViewController" bundle:nil];
gameEndingView.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:gameEndingView animated:YES];
[gameEndingView release];
I want to show the score that I attained in the main gameloop in this gameEndingView that I have. However, it seems that when I use presentModalViewController method to switch view. The variable, score, that I update during the gameloop gets reseted. My whole game loop is in a view gameMainView.
Could someone explain to me about the use of presentModalViewController and how should I better solve my problem?
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是你的模态视图的问题。您的应用程序逻辑有问题。你最好再检查一下。
好主意是将分数声明为属性并设置一个断点,以便您可以看到它的更改位置。
This is not the problem with your modal view. You have a problem in the app logic. You should better check this out again.
The good idea would be declaring the score as the property and set a breakpoint so you could see where it is changed.