cocos creator 动画脚本

cocos creator 动画脚本

1.创建精灵 : 创建精灵,并将动画脚本设置好。

  

2.编写脚本

   要在start 中增加动画显示,如果在onload 中增加,就会报错,提示getChildByName找不到目标。


    start () {
        var animNode = this.node.getChildByName("SolarisiusGalaxy");  //父级节点获取
        var anim = animNode.getComponent(cc.Animation);
        anim.play("Galaxy");

        var anim_dna_Node = this.node.getChildByName("MolecularDNA");
        var anim_dna = anim_dna_Node.getComponent(cc.Animation);
        anim_dna.play("DNA");
    },

猜你喜欢

转载自www.cnblogs.com/Siegel/p/12525675.html