首先简单说下我的实现逻辑:
我写了个GameObject 继承CCSprite实现 update(float dt),然后Monster继承GameObject实现update(float dt).为何,我不管在GameObject实例化时候执行scheduleUpdateWithPriority还是Monster实例化时候执行scheduleUpdateWithPriority都只是GameObject中的Update执行的?
我想最后继承类Monster中update能运行,并且父类GameObject中的update也能执行。
就是不懂为何virtual update(float dt)已经都在GameObject和Monster中重写了,还是不行,只提示GameObject中的Update运行。
解决过程研究:
1、我以为在Monster初始化时候启动schedule一下update方法让它每侦执行。可惜也不会启动起来。
经过研究发现CCNode中关于schedule部分是这么介绍的
/** schedules the "update" method. It will use the order number 0. This method will be called every frame.
Scheduled methods with a lower order value will be called before the ones that have a higher order value.
Only one "update" method could be scheduled per node.
@since v0.99.3
*/
void scheduleUpdate(void);
所以不能同时存在2个update方法!然后我把Monster里面的update换成updateMonster(float dt),然后用schedule启动一下。果然成功了。
492



被折叠的 条评论
为什么被折叠?



