Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88774

外部导入资源创建骨骼动画(dragonbones)

$
0
0

@745872343 写道:

骨骼动画的资源如下:

若将资源放置于resources,中

可直接通过代码创建

     var self = this;
    // dragonbones 是 resources 文件夹中存放 DragonBones 资源的文件夹名称
    cc.loader.loadResAll('dragonbones', function (err, assets) {

        cc.log('骨骼动画资源:' + assets);

        let node = new cc.Node('1213');
        self.node.addChild(node, 99999);
        node.setPosition(cc.p(200, 200));
        let armatureDisplay = node.addComponent(dragonBones.ArmatureDisplay);

        for (let i = 0; i < assets.length; i++) {
            if (assets[i] instanceof dragonBones.DragonBonesAsset) {
                armatureDisplay.dragonAsset = assets[i];

                 cc.log('dragonBones.DragonBonesAsset ' + i + ' :'+ assets[i]);
            }

            if (assets[i] instanceof dragonBones.DragonBonesAtlasAsset) {
                armatureDisplay.dragonAtlasAsset = assets[i];

                cc.log('dragonBones.DragonBonesAtlasAsset ' + i + ' :'+ assets[i]);
            }
        }
        armatureDisplay.armatureName = 'mecha_1502b';
        armatureDisplay.playAnimation('idle', -1);
    });

资源在setttings.js中记录为:

        "1576a513-515f-4a0f-abd9-4d8879622d16": [
            "resources/dragonbones/CoreElement_texture_1.json",
            "dragonBones.DragonBonesAtlasAsset"
        ],
        "a6ffc54a-4de1-44f0-aff7-c225179f14f8": [
            "resources/dragonbones/CoreElement_texture_1.png",
            "cc.Texture2D"
        ],
        "8bdf6102-832f-4503-b145-19d9e2c3d364": [
            "resources/dragonbones/CoreElement_texture_1",
            "cc.SpriteFrame",
            1
        ],
        "8dcba141-f8a4-4c16-bf0d-76f1cfd53345": [
            "resources/dragonbones/CoreElement.json",
            "dragonBones.DragonBonesAsset"
        ],

但我需要用外部导入的资源创建骨骼动画,资源放置于项目外,通过cc.loader.load()获取资源。但这样获取到的资源是三个文件:

求问大神有没有办法将资源转为骨骼动画要求的资源格式,或者有没有其他可以创建骨骼动画的方法~

帖子: 13

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88774

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>