Creator龙骨动画active=false切换场景时会暴崩

2020-05-19  本文已影响0人  浪荡少年

原因可能是引擎的问题,如果遇到这种暴崩的问题,请把龙骨动画的渲染模式从sharder cache模式转换成Realtime模式,然后如果需要换皮的时候代码写

     * 加载本地SkeletonData数据

     * @param DataPath        路径("Game/Person/Cook/cook_show_1")

     * @param Success         设置成功的回调 

     */

    async setLongguData(DataPath: string, armatureName, Success: () => void = function () { }) {

        if (this.getLonggu() == undefined) {

            this.collectError("未添加龙骨组件组件,无法设置LongguData");

            return;

        }

        await this.loadLongguData(DataPath + '_ske', (outputSkeletonData) => {

            this.selfLonggu.dragonAsset = outputSkeletonData;

            cc.loader.loadRes(DataPath + '_tex', dragonBones.DragonBonesAtlasAsset, (err, lgData) => {

                if (err) {

                    console.log(err);

                    return;

                }

                this.selfLonggu.dragonAtlasAsset = lgData;

                this.selfLonggu.armatureName = armatureName;

                Success();

            });

        });

    }

    /**

    * 得到龙骨组件

    */

    public getLonggu() {

        if (this.selfLonggu == undefined) {

            this.selfLonggu = this.getComponent(dragonBones.ArmatureDisplay);

            if (this.selfLonggu == undefined) {

                this.selfLonggu.getComponentInChildren(dragonBones.ArmatureDisplay);

            }

        }

        if (this.selfLonggu == undefined) {

            this.collectError("未添加龙骨组件");

            return undefined;

        }

        return this.selfLonggu;

    }

    /**

     * 加载本地LongguData数据

     * @param DataPath        路径("Game/Person/Cook/cook_show_1")

     * @param loadSuccess     加载成功的回调

     */

    public loadLongguData(DataPath: string, loadSuccess: (outputSkeletonData: dragonBones.DragonBonesAsset) => void) {

        cc.loader.loadRes(DataPath, dragonBones.DragonBonesAsset, function (err, spData) {

            if (err) {

                console.log(err);

                return;

            }

            loadSuccess(spData);

        });

    }

上一篇下一篇

猜你喜欢

热点阅读