[已解决]COCOS2D-JS在jsb下  Sequence的callfunc里执行animate有问题?在web下就没问题

moveToTarget:function(){
    var preDir=this.changeDir;
    this.curStep++;
    var dir=this.changeDir;
    var next=this.curStep;
    if(next>=this.wayTiles.length){
       this.moveEndAttack();
       this.moveOut();
        //console.log("move out");
       return;
    }
    //方向变化
    if(preDir!=dir){
       this.sprite.stopAllActions();
        var animation1 = cc.Animation.create(this.dirAnim, 0.2);
        var animate1 = cc.Animate.create(animation1);
       //var action = cc.ScaleBy.create(0.2, 0.5);
        this.sprite.runAction(cc.RepeatForever.create(animate1));
        //


       //
    }
    var curPoint=cc.p(this.wayTiles.x+40,this.wayTiles.y+80);
    var moveTo= cc.MoveTo.create(this.speed, curPoint);
    var nextMove=cc.CallFunc.create(this.moveToTarget, this);
    var moveSeq=cc.Sequence.create(moveTo,nextMove);
    this.runAction(moveSeq) ;
},

这里:
var animation1 = cc.Animation.create(this.dirAnim, 0.2);
var animate1 = cc.Animate.create(animation1);
//var action = cc.ScaleBy.create(0.2, 0.5);
this.sprite.runAction(cc.RepeatForever.create(animate1));

在jsb下有问题,在web下没问题

在jsb下报什么错误呢

不报错,就是动画不执行

建议可以断点调试下,看看在jsb下各个变量的值是否正常

我把animation改成scaleby就没问题,代码如下
var animation1 = cc.Animation.create(this.dirAnim, 0.2);
var animate1 = cc.Animate.create(animation1);
var action = cc.ScaleBy.create(0.2, 0.5);
this.sprite.runAction(action);

所以感觉是在Sequence的callfunc里调用animation有问题,同样的代码在web下是没有问题的

楼主,this.dirAnim里的东西怎么创建的啊,目测是没有retain造成的。

    this.heroTexture=cc.textureCache.addImage(imageName);
        var dirArray='down','up','left','right'];
        for(var i in dirArray){
            this.dirAnim]=];
            for(var j=0;j<4;j++){
                this.dirAnim].push(cc.SpriteFrame.create(this.heroTexture,cc.rect(74*j,100*i,74,100)));
            }
        }

我的功能其实就是一个hero沿着一定的路线行走,当方向改变的时候改变sprite的动画图片

this.dirAnim.push(cc.SpriteFrame.create(this.heroTexture,cc.rect(74j,100i,74,100)));
这一行换成下面的试试
var spriteFrame = cc.SpriteFrame.create(this.heroTexture,cc.rect(74j,100i,74,100));
spriteFrame.retain();
this.dirAnim.push(spriteFrame);

果然ok…,看来玩jsb需要自己管理内存。。。。

目前jsb的内存管理方式是和cocos2d-x一样的,对大部分引擎里的类,你创建一个对象但是没有立即使用它(比如addChild),而是暂存起来,都需要retain一下,让他的引用计数加1,等到你不需要使用了,再release一下,引用计数减1.