CVP认证学习笔记--李天宇022使用animationEditor编辑帧动画

本节课主要学习了如何使用Animation Editor制作帧动画和如何在cocosjs环境下加载这些帧动画。首先通过查阅资料:

添加骨骼文件信息,由骨骼数据管理器管理。采用ccs.ArmatureFileInfo这个类添加动画文件,然后添加动画层,然后播放哪一帧的动画。当然在此之前一定要在我们的配置文件中加入”extensions”,只有加入这个才可以用cocostudio的内容......还有不能忘记在Resuorce.js添加.plist  .png  .json文件。具体代码如下:
var HelloWorldLayer = cc.Layer.extend({
    sprite:null,
    isAttack:null,
    ctor:function () {
        this._super();
        var size = cc.winSize;
        cc.eventManager.addListener({
            event:cc.EventListener.TOUCH_ONE_BY_ONE,
            swallowTouches:true,
            onTouchBegan:this.ontouchbegan.bind(this),
            onTouchMoved:this.ontouchmoved,
            onTouchEnded:this.ontouchended.bind(this)
        },this);
        //添加动画文件
        ccs.armatureDataManager.addArmatureFileInfo(res.ani_attack_json);
        //添加动画层
        var ani = new ccs.Armature("NewAnimationAttack");
        //添加标记
        ani.setTag(100);
        ani.setPosition(size.width/2,size.height/2);
        this.addChild(ani);
        return true;
    },
    ontouchbegan: function (touch,event) {
        var ani = event.getCurrentTarget().getChildByTag(100);
            //播放刚刚添加的动画
            ani.getAnimation().playWithIndex(0);
            this.isAttack=false;
            //当动画播放结束后,执行监听
            ani.getAnimation().setMovementEventCallFunc(this.animationEvent,this);
        return true;
    },
    animationEvent:function (armature,movementType,movementID) {
        var size = cc.winSize;
        if(!this.isAttack){
            //移除之前的动画
            this.removeChildByTag(100);
            ccs.armatureDataManager.addArmatureFileInfo(res.ani_walk_json);
            var ani1 = new ccs.Armature("NewAnimationWalk");
            ani1.getAnimation().playWithIndex(0);
            ani1.getAnimation().s
            ani1.setPosition(size.width/2,size.height/2);
            this.addChild(ani1);
        }
    },
    ontouchmoved:function(){
        
    },
    ontouchended: function () {
    }
});

var HelloWorldScene = cc.Scene.extend({
    onEnter:function () {
        this._super();
        var layer = new HelloWorldLayer();
        this.addChild(layer);
    }
});

最后附上作业链接:

http://www.cocoscvp.com/usercode/3355e343a7cf923a23fbfb9cbf9551b1b6e73f48/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值