在xcode中使用presentModalViewController切换视图时检索分数

发布于 2024-10-14 10:56:33 字数 640 浏览 2 评论 0原文

我面临着在某人完成游戏后检索游戏“高分”的问题。

我所做的是:

当时间达到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

水晶透心 2024-10-21 10:56:33

这不是你的模态视图的问题。您的应用程序逻辑有问题。你最好再检查一下。
好主意是将分数声明为属性并设置一个断点,以便您可以看到它的更改位置。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文