切换到另一个自定义视图
我是 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技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的方法是将所有视图放入 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.