zoukankan      html  css  js  c++  java
  • 【Cocos2d-x-js系列】利用动画缓存来复用动画

    OnWalkClick:function(sender){
            var sfLaoJun1=new cc.SpriteFrame(res.npc_laojun1,cc.rect(0,0,70,101));
            var sfLaoJun2=new cc.SpriteFrame(res.npc_laojun2,cc.rect(0,0,70,101));
            var sfLaoJun3=new cc.SpriteFrame(res.npc_laojun3,cc.rect(0,0,70,101));
            var sfLaoJun4=new cc.SpriteFrame(res.npc_laojun4,cc.rect(0,0,70,101));
            var sfLaoJunAll=new Array(sfLaoJun1,sfLaoJun2,sfLaoJun3,sfLaoJun4);
            var amnLaoJun=new cc.Animation(sfLaoJunAll,0.05);
            var action=cc.animate(amnLaoJun);
            var sprite=new cc.Sprite();
            sprite.setPosition(160,300);
            this.addChild(sprite);
            cc.animationCache.addAnimation(amnLaoJun,"LaoJun");
            sprite.runAction(cc.repeatForever(action));
        },
        OnSpriteFrameCacheTesting: function (sender) {
            var  amnLaoJun=cc.animationCache.getAnimation("LaoJun");
            var  amtLaoJun=new cc.Animate(amnLaoJun);
            var  sprite=new cc.Sprite();
            sprite.setPosition(160,400);
            this.addChild(sprite);
            sprite.runAction(cc.repeatForever(amtLaoJun));
    
        }

    依然感谢张翼翔先生。

  • 相关阅读:
    写在noi之前
    雅礼集训 Day8
    雅礼集训 Day6
    雅礼集训 Day5
    2017雅礼集训 Day4
    2017雅礼集训 Day2
    2017雅礼集训 Day1
    洛谷 P3426 [POI2005]SZA-Template
    Codeforces Round #368 DIV2 C.
    Educational Codeforces Round 16 D&E.
  • 原文地址:https://www.cnblogs.com/yanyuge/p/4043795.html
Copyright © 2011-2022 走看看