zoukankan      html  css  js  c++  java
  • 【插件】CocosCreator Spine在场景编辑器实时预览(论坛水友分享的)

    参考:

    ( 完美解决)spine在场景编辑器不能实时预览动作的问题

    下载地址:SkeletonExt.zip

    逛论坛看到这个spine实时预览的解决方案,不需要改动源码,觉得十分的方便。

    将文件SkeletonExt.js放在项目目录文件夹libs下,勾选运行编辑器加载即可。

    spine预览效果

    源码的位置:

    SkeletonExt.js完整代码:

    cc.game.once(cc.game.EVENT_ENGINE_INITED, function () {
    
        cc.js.mixin(sp.Skeleton.prototype, {
            update (dt) {
                // if (CC_EDITOR) return;
                
                if (CC_EDITOR) {
                    cc.engine._animatingInEditMode = 1;
                    cc.engine.animatingInEditMode = 1;
                }
    
                if (this.paused) return;
        
                dt *= this.timeScale * sp.timeScale;
        
                if (this.isAnimationCached()) {
        
                    // Cache mode and has animation queue.
                    if (this._isAniComplete) {
                        if (this._animationQueue.length === 0 && !this._headAniInfo) {
                            let frameCache = this._frameCache;
                            if (frameCache && frameCache.isInvalid()) {
                                frameCache.updateToFrame();
                                let frames = frameCache.frames;
                                this._curFrame = frames[frames.length - 1];
                            }
                            return;
                        }
                        if (!this._headAniInfo) {
                            this._headAniInfo = this._animationQueue.shift();
                        }
                        this._accTime += dt;
                        if (this._accTime > this._headAniInfo.delay) {
                            let aniInfo = this._headAniInfo;
                            this._headAniInfo = null;
                            this.setAnimation (0, aniInfo.animationName, aniInfo.loop);
                        }
                        return;
                    }
        
                    this._updateCache(dt);
                } else {
                    this._updateRealtime(dt);
                }
            }
        })
    
    })

     

  • 相关阅读:
    字符串与Unicode码的相互转换
    关于es6中的yield
    ajax请求中的6个全局事件
    用H5上传文件
    类型化数组
    git笔记-9-29
    js正则表达式验证身份证号和密码
    assertThat用法
    java产生随机数的几种方式
    jQuery之Deferred对象详解
  • 原文地址:https://www.cnblogs.com/gamedaybyday/p/14776023.html
Copyright © 2011-2022 走看看