[英]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.