Assertion failure: thing, at...gc/Marking.cpp:112

 

 

遇到个jsb的bug,全公司的人整整折腾了2天!!

描述:

下面代码,在GC后,程序崩溃,错误log输出如下:

Assertion failure: thing, at /Users/james/Project/Spidermonkey/js/src/gc/Marking.cpp:112

代码:

var FightActionAttack = cc.Class.extend({
    init: function (attacker) {
        var self = this;
        attacker.getAnimation().play("normalAttack");
        attacker.getAnimation().setMovementEventCallFunc(this._movementAttackEvent, this);
    },

    _movementAttackEvent: function (armature, movementType, movementID) {

    },

    _frameAttackEvent: function (bone, evt, originFrameIndex, currentFrameIndex) {

    }
});

原因:

cocos2d-x 2.x版本的jsb中,不能使用继承只cc.Class的对象做CallbackFunc的回调target,

因为这种直接集成自cc.Class的对象做callback回调的target,会把gc搞崩溃。 

解决办法是,集成cc.Node

你可能感兴趣的:(assert)