iOS编程中模型和视图之间的数据通信
我正在从头开始构建一款 iPhone 横向卷轴视频游戏。我有一个敌人模型,需要改变敌人手臂和腿的位置。我需要将这些更改传达给视图以进行显示。我是否应该在模型中使用 NSTimer 来更改这些位置,然后让 ViewController 基于 KVO 观察这些更改,并让 ViewController 将信息发送到 View,并让视图调用 setNeedsDisplay?当然,我希望拥有尽可能最快的帧速率。
I am constructing an iPhone side-scroll video game from the ground up. I have an Enemy model that needs to change the position of an enemy's arms and legs. I need to communicate those changes to the view for display. Should I use an NSTimer inside the model to change those positions, and then have the ViewController observe those changes based on KVO, and have the ViewController send the information to the View, and have the view call setNeedsDisplay? Naturally, I want to have the fastest frame rate possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这听起来是一个合理的方法。
That sounds like a reasonable way to do it.