切换到另一个自定义视图

发布于 2024-12-04 02:19:04 字数 190 浏览 0 评论 0原文

我是 Objective-C 编程的新手。现在,我正在创建一个可可游戏应用程序。

与许多游戏应用程序一样,我创建的游戏有多个视图。我已经准备好了自定义视图,现在我的问题是当我单击按钮时更改视图...就像在我的主菜单中一样,我有播放、说明和高分等选项。当玩家单击指令按钮时,视图应该切换到我创建的指令视图...

你能帮我解决这个问题吗?

i am just new to objective-c programming. now, i am creating a cocoa game application.

like many game apps, the game that i created has multiple views. i have already prepared the custom view, and now my problem is changing the view when i click a button... like in my main menu, i have options like play, instructions and high score. when the player clicks instructions button, the view should switch to the instructions view that i created...

can you help me with this one?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

夏雨凉 2024-12-11 02:19:04

最简单的方法是将所有视图放入 NSTabView,只需切换选项卡即可。 (“选项卡”不必具有可见的选项卡。您可以拥有无​​表选项卡视图。)

更难但更容易制作动画的是操作视图层次结构。从其超级视图中取出当前视图,并将当前视图添加为新的子视图。* 核心方法位于 NSView;对这些过渡进行动画处理的最简单方法是与视图的 动画师代理

更多相关文档:

*不要忘记在加载窗口后立即保留所有游戏模式视图,这样当您将每个视图从超级视图中取出时,它们就不会消失。

The simplest way is to put all of the views into an NSTabView, and just switch the tab. (The “tabs” don't have to have visible tabs. You can have a tabless tab view.)

Harder, but easier to animate, is to manipulate the view hierarchy. Take what was the current view out of its superview, and add what will be the current view as the new subview.* The core methods for this are in NSView; the simplest way to animate these transitions is to talk to the views' animator proxies.

More relevant documentation:

*Don't forget to retain all of the game-mode views just after loading the window, so they don't die on you when you take each one out of the superview.

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