DragonBones / DragonBonesJS

DragonBones TypeScript / JavaScript Runtime
MIT License
746 stars 321 forks source link

In Phaser 3 - Armature no wanna loading after scene changing! #143

Open MadDogMayCry0 opened 4 years ago

MadDogMayCry0 commented 4 years ago

After scene changing armature stops loading, when it's has a same name. Pls, fix it. And animation stops working after scene.scene.restart();

<script>
        let config = {
            type: Phaser.WEBGL,
            <!-- physics: { -->
            <!-- default: 'arcade', -->
            <!-- arcade: { -->
                <!-- gravity: { y: 300 }, -->
                <!-- debug: false -->
            <!-- } -->
            <!-- }, -->
            scale: {
                mode: Phaser.Scale.FIT,
                autoCenter: Phaser.Scale.CENTER_BOTH,
                width: 1920,
                height: 1080
            },
            audio: {
                disableWebAudio: true
            },
            plugins: {
                scene: [
                    { key: "DragonBones", plugin: dragonBones.phaser.plugin.DragonBonesScenePlugin, mapping: "dragonbone" }
                ]
            },
        };

    var SceneA = new Phaser.Class({

    Extends: Phaser.Scene,

    initialize:

    function SceneA ()
    {
        Phaser.Scene.call(this, { key: 'sceneA' });
    },

    preload: function ()
    {
        this.load.dragonbone("doc",
    "characters/doc/doc_tex.png",
    "characters/doc/doc_tex.json",
    "characters/doc/doc_ske.json");
    },

    create: function ()
    {
        this.add.armature("doc_test", "doc");

        this.input.once('pointerdown', function () {
           this.scene.start('sceneB');

        }, this);
    }

});

var SceneB = new Phaser.Class({

    Extends: Phaser.Scene,

    initialize:

    function SceneB ()
    {
        Phaser.Scene.call(this, { key: 'sceneB' });
    },

    preload: function (){
        this.load.dragonbone("doc",
    "characters/doc/doc_tex.png",
    "characters/doc/doc_tex.json",
    "characters/doc/doc_ske.json");
    },

    create: function ()
    {
        this.add.armature("doc_test", "doc");

        this.input.once('pointerdown', function (event) {
           this.scene.start('sceneA');

        }, this);
    },

    update: function (time, delta){

    }

});

var game = new Phaser.Game(config);
game.scene.add('SceneA', SceneA);
game.scene.add('SceneB', SceneB,true);
</script>
MadDogMayCry0 commented 3 years ago

fixed