叫我PT 2019-03-24 00:09 采纳率: 100%
浏览 582
已结题

学cocos在引入spine的示例的脚本中遇到一些困难,就是trackentry究竟是什么

在spine类下也没有找到相应的属性。。。但是函数列表却有。。。

cc.Class({
extends: cc.Component,
editor: {
requireComponent: sp.Skeleton
},

properties: {
    mixTime: 0.2
},

onLoad () {
    var spine = this.spine = this.getComponent('sp.Skeleton');
    this._setMix('walk', 'run');
    this._setMix('run', 'jump');
    this._setMix('walk', 'jump');

    spine.setStartListener(trackEntry => {
        var animationName = trackEntry.animation ? trackEntry.animation.name : "";//就在这里!!!!而且这整个函数是干嘛的我也不理解??
        cc.log("[track %s][animation %s] start.", trackEntry.trackIndex, animationName);
    });
    spine.setInterruptListener(trackEntry => {
        var animationName = trackEntry.animation ? trackEntry.animation.name : "";
        cc.log("[track %s][animation %s] interrupt.", trackEntry.trackIndex, animationName);
    });
    spine.setEndListener(trackEntry => {
        var animationName = trackEntry.animation ? trackEntry.animation.name : "";
        cc.log("[track %s][animation %s] end.", trackEntry.trackIndex, animationName);
    });
    spine.setDisposeListener(trackEntry => {
        var animationName = trackEntry.animation ? trackEntry.animation.name : "";
        cc.log("[track %s][animation %s] will be disposed.", trackEntry.trackIndex, animationName);
    });
    spine.setCompleteListener((trackEntry) => {
        var animationName = trackEntry.animation ? trackEntry.animation.name : "";
        if (animationName === 'shoot') {
            this.spine.clearTrack(1);
        }
        var loopCount = Math.floor(trackEntry.trackTime / trackEntry.animationEnd); 
        cc.log("[track %s][animation %s] complete: %s", trackEntry.trackIndex, animationName, loopCount);
    });
    spine.setEventListener((trackEntry, event) => {
        var animationName = trackEntry.animation ? trackEntry.animation.name : "";
        cc.log("[track %s][animation %s] event: %s, %s, %s, %s", trackEntry.trackIndex, animationName, event.data.name, event.intValue, event.floatValue, event.stringValue);
    });

    this._hasStop = false;
},

// OPTIONS

toggleDebugSlots () {
    this.spine.debugSlots = !this.spine.debugSlots;
},

toggleDebugBones () {
    this.spine.debugBones = !this.spine.debugBones;
},

toggleTimeScale () {
    if (this.spine.timeScale === 1.0) {
        this.spine.timeScale = 0.3;
    }
    else {
        this.spine.timeScale = 1.0;
    }
},

// ANIMATIONS

stop () {
    this.spine.clearTrack(0);
    this._hasStop = true;
},

walk () {
    this.spine.setAnimation(0, 'walk', true);
    this._hasStop = false;
},

run () {
    this.spine.setAnimation(0, 'run', true);
    this._hasStop = false;
},

jump () {
    var oldAnim = this.spine.animation;
    this.spine.setAnimation(0, 'jump', false);
    if (oldAnim && !this._hasStop) {
        this.spine.addAnimation(0, oldAnim === 'run' ? 'run' : 'walk', true, 0);
    }
},

shoot () {
    this.spine.setAnimation(1, 'shoot', false);
},

//

_setMix (anim1, anim2) {
    this.spine.setMix(anim1, anim2, this.mixTime);
    this.spine.setMix(anim2, anim1, this.mixTime);
}

});

  • 写回答

1条回答 默认 最新

  • devmiao 2019-03-24 23:45
    关注
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题