DragonBonesJS icon indicating copy to clipboard operation
DragonBonesJS copied to clipboard

Phser 3.x Multi Scene

Open cpet opened this issue 5 years ago • 11 comments
trafficstars

I am trying to get the dragonbones plugin to work (show an animated character) in more than 1 scene. Things I've tried: Global Pluging setup. Scene plugin. Tried to 'removeScenePlugin' in the first scene then install the plug-in again in the second one. Nothing Phaser 3 plugin related seem to work.

Observations:

The problem always arises when I call the 'this.add.armature("NameOfCharacterArmature", "NameOfDbFile");' in the first scene. It works in the first one, and draws nothing but blanks in the second.

The armature itself is created, the slots are defaults (32x32 transparent default images).

Anyone knows a way besides limiting the dragonbones animations to one scene?

cpet avatar Jan 14 '20 02:01 cpet

hi, can you check if your issue is the same one with https://github.com/DragonBones/DragonBonesJS/issues/119?

jcyuan avatar Jan 14 '20 03:01 jcyuan

I looked at it; there are similarities indeed. It looks like he cleverly works around the problem by loading the same dragonbones animations twice but with a different name for each scene. As I said above my models load almost correctly, whatever method is in charge with assigning the right frames in the right slots is failing on the second scene... there's something that tells it to skip the process so we end up having animated characters with 32 by 32 pixels images on each bone slot.

I'll try his workaround to see if I'm getting it to work. Hope that helps with finding out a solution. Thanks!

cpet avatar Jan 14 '20 06:01 cpet

So it looks like the different names workaround worked for me as well.

For the time being I'm trying to organize my characters on a as per needed basis, meaning I'm trying not to have too many overlapping characters needed in multiple scenes but rather have specific scenes where they appear. This helps with texture / memory managements.

I mean, compared to the sprite sheet approach dragonbones already saves a lot. My guess is, this fix could also make it a good choice against other similar tooling, assuming their phaser3 api works in multi scene.

cpet avatar Jan 14 '20 14:01 cpet

this will be fixed in next release.

jcyuan avatar Jan 15 '20 08:01 jcyuan

@jcyuan hello jcyuan,

any news about this bug? I can't use dragonebones character in next scene too. :(

MadDogMayCry0 avatar Jun 25 '20 06:06 MadDogMayCry0

@cpet @jcyuan Hey, I have submitted a fix/workaround that I use in my game, posted in #140 . It works for changing scenes, however if you want to use the same rig in 2 scenes running parallel you still have to use the different name trick.

So I have a single separate rig for my inventory, but am able to use the main rig throughout all other scenes.

faradaym avatar Sep 04 '20 19:09 faradaym

I fixed by editing DragonBonesPlugin.ts , add "ee.once('start', this.start, this);" to function shutdown( ).

shutdown(): void { const ee = this.systems.events; ee.once('start', this.start, this); ee.off('update', this.update, this); ee.off('shutdown', this.shutdown, this); }

twachikku avatar Sep 10 '20 03:09 twachikku

Is this going to be officially fixed anytime soon? We're running into the same issue, and the workaround does work, but deciding whether to go forward with Dragonbones or not is a large financial decision that's fairly uncomfortable to make when support is dependent on a workaround.

Thanks to you guys who found workarounds!

SonicZentropy avatar Sep 26 '20 07:09 SonicZentropy

@SonicZentropy Dragonbones is a very unstable story when it comes to phaser. There is no official support for dragonbones at the moment. Richard does not appear to be working on an official plugin to support dragonbones in phaser, and I cannot say for sure that he did not voice the reasons. This plugin is completely inoperable in phaser and you'd better find another engine if you want to use dragonbones in production.

MadDogMayCry0 avatar Sep 26 '20 08:09 MadDogMayCry0

@MadDogMayCry0 that's really unfortunate to hear. I really wish we were not using Phaser for other reasons already, so I'll just add this one ot the list. Thanks for letting me know!

SonicZentropy avatar Oct 09 '20 14:10 SonicZentropy

@SonicZentropy You can use some fixes to get it works. Animation after scene changing, and next scene character loading. Take a look here - https://github.com/MadDogMayCry0/Phaser-3-DragonBones-plugin-with-bad-fixes See sourcecode of files to understand how it works.

MadDogMayCry0 avatar Oct 10 '20 07:10 MadDogMayCry0