// Learn cc.Class: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html // Learn Attribute: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html // Learn life-cycle callbacks: // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html cc.Class({ extends: cc.Component, properties: { // foo: { // // ATTRIBUTES: // default: null, // The default value will be used only when the component attaching // // to a node for the first time // type: cc.SpriteFrame, // optional, default is typeof default // serializable: true, // optional, default is true // }, // bar: { // get () { // return this._bar; // }, // set (value) { // this._bar = value; // } // }, }, // LIFE-CYCLE CALLBACKS: // onLoad () {}, start () { player = this this.An = this.node.getComponent(cc.Animation) this.Animations = utils.getAnimations(this.An); Log.info("所有表演",this.Animations) }, leftok(b){ // Log.info("打到了",b) if (this.LeftokListener) { this.LeftokListener(); } }, rightok(b){ // Log.info("打到了",b) if (this.RightokListener) { this.RightokListener(); } }, //左侧击打监听 setLeftokListener(LeftokListener){ this.LeftokListener = LeftokListener; }, setRightokListener(RightokListener){ this.RightokListener = RightokListener; }, // initListener(){ // utils.setAnimationCallBack(this.An,"finished",,function () { // Log.info("现在回来的是什么") // }.bind(this)); // }, playLeft(){ this.nowPlaying(function () { utils.startAnimation(this.An,this.Animations[1].name); // this.initListener(); utils.setAnimationCallBack(this.An,"finished",this.Animations[1].name,function () { // Log.info("现在回来的是什么",this.Animations[1].name) this.setAn_normal(); }.bind(this)); }.bind(this)); }, playRight(){ this.nowPlaying(function () { utils.startAnimation(this.An,this.Animations[2].name); utils.setAnimationCallBack(this.An,"finished",this.Animations[2].name,function () { // Log.info("现在回来的是什么",this.Animations[2].name) this.setAn_normal(); }.bind(this)); }.bind(this)); }, playMid(){ this.nowPlaying(function () { utils.startAnimation(this.An,this.Animations[3].name); utils.setAnimationCallBack(this.An,"finished",this.Animations[3].name,function () { // Log.info("现在回来的是什么",this.Animations[3].name) this.setAn_normal(); }.bind(this)); }.bind(this)); }, playLeftBad(){ this.nowPlaying(function () { utils.startAnimation(this.An,this.Animations[4].name); utils.setAnimationCallBack(this.An,"finished",this.Animations[4].name,function () { // Log.info("现在回来的是什么",this.Animations[3].name) this.setAn_normal(); }.bind(this)); }.bind(this)); }, playRightBad(){ this.nowPlaying(function () { utils.startAnimation(this.An,this.Animations[5].name); utils.setAnimationCallBack(this.An,"finished",this.Animations[5].name,function () { // Log.info("现在回来的是什么",this.Animations[3].name) this.setAn_normal(); }.bind(this)); }.bind(this)); }, setAn_normal(){ utils.startAnimation(this.An,this.Animations[0].name); }, //动画播放中 nowPlaying(callback){ // Log.info("当前播放的是",this.An.currentClip ,this.Animations[0].name) if (this.An.currentClip == null || this.An.currentClip.name ==this.Animations[0].name ) { if (callback) { callback(); } } } // update (dt) {}, });