在 cocos2d 中处理游戏循环
如何同时处理游戏的多个元素?
在背景/图块地图在每个游戏循环中移动的滚动条中,如何同时处理用户输入?
地图需要在游戏循环中移动,需要检查玩家对象和地图上不应该碰撞的部分的碰撞,还需要一些代码来接受用户输入,在地图上移动玩家并也检查碰撞吗?
这些应该是线程化的还是在 cocos2d 中如何完成这些?
有没有内置的方法?
How does one handle multiple elements of a game at once?
In a scroller which the background/tilemap moves every gameloop how is the user input handled at the same time?
The map needs to be moved in the game loop and collision needs to be checked for the player object and parts of the map which it shouldnt hit, and there also needs to be code which takes the user input, moves the player on the map and checks for collisions too?
Should these be threaded or how are these done in cocos2d?
Are there any built in methods?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
注册具有指定间隔的步骤方法。
尝试并避免注册多个步骤方法。您可以一步完成您需要的一切。您不需要使用线程。
Register a step method with a specified interval.
Try and avoid registering multiple step methods. You can do everything you need in one step method. You don't need to use threading.
最好注册更新方法
,然后根据需要重写更新方法,
这将由 cocos2d 在游戏的每一帧中更准确地调用,而不是安排新的更新方法。
(Cocos2dx 版本:
this->scheduleUdate()
,void update(float delta);
)It is prefer to register the update method
Then override the update method as you like
this will be called in every frame of your game more accurately by the cocos2d than schedule a new one.
(Cocos2dx version:
this->scheduleUdate()
,void update(float delta);
)