| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- // 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) {},
- });
|