我不应该继承 Cocos2d CCDirector 类吗?

发布于 2024-11-11 18:02:07 字数 128 浏览 5 评论 0原文

我正在尝试让 cocos2d 成为 RPG 引擎。我正在考虑创建一个类来协调角色的移动、地图加载/卸载等。我应该为此创建一个 CCNode,还是只是扩展 CCDirector?有没有理由不子类化CCDirector

I'm trying to make cocos2d work as an RPG engine. I'm thinking of making a class that will coordinate the movements of the characters, the map loading/unloading etc. Should I make a CCNode for this, or just extend the CCDirector? Is there a reason not to subclass the CCDirector?

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

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

发布评论

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

评论(1

爱格式化 2024-11-18 18:02:07

除了cocos2d中的子类(CCDirectorDisplayLink、CCDirectorTimer等)之外,我从未见过CCDirector的子类。允许创建 CCDirector 的子类,但实际上并不需要。

如果您想要为每个帧调用一个方法,可以使用 CCScheduler -scheduleSelector:forTarget:interval:paused: 方法。它将调用主循环中每一帧的选择器。

[[CCScheduler sharedScheduler]
    scheduleSelector:@selector(tick:) forTarget:self interval:0 paused:NO];

CCScene 可以用于加载/卸载资源数据等。

另外,这些教程怎么样?

I have never seen a subclass of CCDirector except the subclasses in cocos2d (CCDirectorDisplayLink, CCDirectorTimer or so on). Subclasses of CCDirector are allowed to create, but it is not really needed.

If you want a method that is invoked for every frame, you can use CCScheduler -scheduleSelector:forTarget:interval:paused: method. It will invoke the selector for every frame from the main loop.

[[CCScheduler sharedScheduler]
    scheduleSelector:@selector(tick:) forTarget:self interval:0 paused:NO];

And CCScene is able to use for loading/unloading resource data, or etc.

Also, how about these tutorials?

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