Cocos2d-x 监听 Action finish

cocos2d-x的Action自身没有提供动画结束的监听逻辑,而是虚拟一个Action和目标action一起组合到Sequence Action中,让虚拟的Action也就是最后一个Action被执行update的时候,进行回调处理。这个虚拟的Action定义如下:


class CC_DLL CallFunc : public ActionInstant //<NScopying>
{
public:
    /** Creates the action with the callback of type std::function<void()>.
     This is the preferred way to create the callback.
     * When this funtion bound in js or lua,the input param will be changed.
     * In js: var create(var func,var this,var [data]) or var create(var func).
     * In lua:local create(local funcID).
     *
     * @param func  A callback function need to be excuted.
     * @return  An autoreleased CallFunc object.
     */
    static CallFunc * create(const std::function<void()>& func);

    /** Creates the action with the callback

     typedef void (Ref::*SEL_CallFunc)();
     @deprecated Use the std::function API instead.
     * @js NA
     * @lua NA
     */
    CC_DEPRECATED_ATTRIBUTE static CallFunc * create(Ref* target,SEL_CallFunc selector);
可见CallFunc继承了ActionInstant,所以CallFunc对于Sequence,ActionManager来说都是普通的Action不需要做特殊操作,也没有什么额外的耦合。

感觉这个地方有点别扭,CallFunc命名完全看不出来跟Action done callback有什么关系,而且这个使用的条件是要通过Sequence Action组合,在Sequence那边也完全没有什么联系,action done 为什么要依赖Sequence呢,想不明白

相关文章

    本文实践自 RayWenderlich、Ali Hafizji 的文章《...
Cocos-code-ide使用入门学习地点:杭州滨江邮箱:appdevzw@1...
第一次開始用手游引擎挺激动!!!进入正题。下载资源1:从C...
    Cocos2d-x是一款强大的基于OpenGLES的跨平台游戏开发...
1.  来源 QuickV3sample项目中的2048样例游戏,以及最近《...
   Cocos2d-x3.x已经支持使用CMake来进行构建了,这里尝试...