Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

菜鸟 问几个问题 用prefeb的时候 修改纹理 然后所有的prefeb 都改变了 有大神可以帮我看看么

$
0
0

@794850991 写道:

//回调函数动画
callbackAnimation : function() {

    var origin = null;
    var card = cc.instantiate(this.cardSprite);
    card.tag = 1000 + this.count;
    card.setPosition(this.bg.width/2,this.bg.height/2);
    card.width = 49;
    card.height = 60.5; 
    //加到背景
    this.bg.addChild(card);
    this.cardArr[this.count] = card;

    //添加监听器到管理器
    this.addListenerEventTouch(card);
    
    //0.改变牌的postion
    if(this.count < 9) {
         origin = cc.p(this.bg.width/2 - this.index + this.count * this.cardWidht, this.cardHeight/2);
    } else {
         origin = cc.p(this.bg.width/2 - this.index + (this.count - this.rowMaxCount) * this.cardWidht, this.cardHeight/2 + this.cardHeight);
    }

    //1.移动动画
    var action = cc.moveTo(this.delay,origin);
    
    //2.压缩动画
    var scaleHide = cc.scaleBy(this.delay, 0,1);
    
    //3.回调函数动画
    var callAction =  cc.callFunc(this.scaleCardSprite, this,card);
     
    //4.创建顺序动画组
    var seq = cc.sequence(action,scaleHide,callAction);

    //5.执行顺序动画组
    card.runAction(seq);

    this.count++;
    
},





    //给当前手牌设置纹理
    var texture = cc.textureCache.addImage(this.imageName);
    this.getComponent(cc.Sprite).spriteFrame.setTexture(texture);
},

 // 产生新牌
newCard:function(row){
    
    //修改纹理
    this.updateSpriteFrame(row);
    
    //翻转动画
    // var scaleShow = cc.scaleTo(this.delay, 1);
    // this.node.runAction(scaleShow);
},

帖子: 3

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>