简体   繁体   English

我不应该继承 Cocos2d CCDirector class 吗?

[英]Should I not be subclassing the Cocos2d CCDirector class?

I'm trying to make cocos2d work as an RPG engine.我正在尝试使 cocos2d 作为 RPG 引擎工作。 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?我正在考虑制作一个 class 来协调角色的移动,map 加载/卸载等。我应该为此制作一个 CCNode,还是只是扩展 CCDirector? Is there a reason not to subclass the CCDirector ?有没有理由不CCDirector

I have never seen a subclass of CCDirector except the subclasses in cocos2d (CCDirectorDisplayLink, CCDirectorTimer or so on).除了 cocos2d 中的子类(CCDirectorDisplayLink、CCDirectorTimer 等),我从未见过 CCDirector 的子类。 Subclasses of CCDirector are allowed to create, but it is not really needed.允许创建 CCDirector 的子类,但这并不是真正需要的。

If you want a method that is invoked for every frame, you can use CCScheduler -scheduleSelector:forTarget:interval:paused: method.如果你想要一个为每一帧调用的方法,你可以使用 CCScheduler -scheduleSelector:forTarget:interval:paused: 方法。 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. CCScene 可以用于加载/卸载资源数据等。

Also, how about these tutorials?另外,这些教程怎么样?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Cocos2d:应该仅使用(id)init进行初始化,还是可以使用(void)onEnter进行后期分配? - Cocos2d: Should I use only (id)init for initializing, or can I use (void)onEnter for late allocation? 是否应该为每个Service方法创建一个单独的DTO类? - Should I create a separate DTO class for each Service method? 不知道我应该把我的方法放在哪个类中 - Not sure which class I should put my method in 我应该如何构建一个由子接口实现者组成的类层次结构? - How should I structure a class heirarchy consisting of interface implementors with children? 我应该避免暴露懒惰吗 <T> 公共API中的类? - Should I avoid exposing the Lazy<T> class in public API? 我应该避免使用类库在Visual Studio中使用“链式”引用吗? - Should I avoid 'chained' references in Visual Studio with class libraries? 我应该如何设计电子商务 Class 图? - How should I design an E-commerce Class Diagram? 我应该使用哪个类名称来对Node.js中的某些数据类型进行CRUD使用 - What class name should I use for a class use to CRUD with some data type in nodejs 哪个班级应该做这项工作? - Which class should do the work? 架构问题:我应该在哪个组件中放置哪个类,以获得干净的解决方案? - Architectural question: In what assembly should I put which class, for a clean solution?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM