creator 重复执行动画闪退

最后一次输出:
17:55:56.974:finished
Simulator: 17:55:56.975:finished 10
Simulator: 17:55:56.976:finished 26
Simulator: 17:55:56.977:finished 3
Simulator: setReturnType not implemented

版本 1.5.1 Android 模拟器都有

finished 回调会被执行多次

你是怎么使用的,有多次注册 finished 消息么

嗯嗯 多次注册了 后面用once来注册finished 来注册

Android还是有闪退 因为这个动画可能短时间会播放多次 我就把它放到对象池了
音乐也preload了
具体代码:

 var ji_dan_animation = null;
                    if(actionPool.size() > 0){
                        window.log("actionPool.size() " + actionPool.size());
                        ji_dan_animation = actionPool.get();
                    }else {
                        ji_dan_animation = cc.instantiate(cc.find("Canvas/animation_jidan_node"));
                    }
                    window.sound.playEffect("prop/interactive_egg.mp3");
                    ji_dan_animation.setPosition(beAtkNodWordPos);
                    parent.addChild(ji_dan_animation);
                    ji_dan_animation.active = true;

                    ji_dan_animation.getChildByName("00").getComponent(cc.Animation).play();
                    ji_dan_animation.getChildByName("00").getComponent(cc.Animation).once('finished',function () {
                        window.log("finished");
                         actionPool.put(ji_dan_animation);
                    });

可以不用匿名函数来作为回调么?匿名函数每次都会被当做一个新的函数来加入。

你可以封装成一个函数来使用

test: function () {
    actionPool.put(ji_dan_animation);
}

ji_dan_animation.getChildByName("00").getComponent(cc.Animation).once('finished', this.test, this);

finished 事件怎么传递参数进去呢 ji_dan_animation 这是一个局部变量

这样?

test: function () {
    actionPool.put(this);
}

ji_dan_animation.getChildByName("00").getComponent(cc.Animation).once('finished', this.test, ji_dan_animation);

嗯嗯 改好了 谢了 我的actionPool挂在this上所以改了改 闪退的几率小了很多很多 看来匿名函数要少用啊
test: function () {
var self = this;
self.actionPool.put(self);
}
ji_dan_animation.actionPool=actionPool;
ji_dan_animation.getChildByName(“00”).getComponent(cc.Animation).once(‘finished’, this.test.bind(ji_dan_animation));

我用cc.callFunc会出现了点问题

var moveAction = cc.moveTo(0.5,beAtkNodWordPos);
var rotateBy = cc.rotateBy(1,1080);
var callFunc = cc.callFunc(self.actionCallFunc,self,{
actionPoolType : actionPoolType + “”,//actionPoolType = 1
moveNode : moveNode,
parent : parent,
beAtkNodWordPos : beAtkNodWordPos
});
moveNode.runAction(cc.spawn(rotateBy,cc.sequence(moveAction,callFunc)));

actionCallFunc : function (event,data) {
var self = this;
//window.log("actionCallFunc " + JSON.stringify(data));
// moveNode.destroy();
//actionPoolType 传入的时候是1 现在接收时有可能为不是1而是一个很大的值
var actionPoolType = parseInt(data.actionPoolType);
if(actionPoolType != window.const.interactive_type.tuo_xie
&& actionPoolType != window.const.interactive_type.dian_zan
&& actionPoolType != window.const.interactive_type.ji_dan
&& actionPoolType != window.const.interactive_type.xian_hua
&& actionPoolType != window.const.interactive_type.di_lei){
//data.moveNode.destroy(); //moveNode也会丢掉
cc.find(“Canvas/interactive_node”).removeAllChildren();
return false;
}
这断代码也会短时间多次调用

这个错误不会引起闪退 但节点没有被隐藏 我就调用它删除创建过的所有节点了
cc.find(“Canvas/interactive_node”).removeAllChildren();