Gui.set_spine_scene is not work while bundle to apk

I use the flowing code to play specific spine animation:

local spine_scenen = detect_witch_spine_scene_to_play()
gui.set_spine_scene(spine_node, spine_scenen)
gui.set_spine_skin(spine_node, 'default')
gui.play_spine_anim(spine_node, 'animation', gui.PLAYBACK_ONCE_FORWARD)

When I bundled it to android application, the animation was not played as usual and the game was hanged caused by it.
But it’s ok in build mode while I choose the target to my android device.

And if you bundle for desktop? Does it work then or is it only on Android that it doesn’t work?

It’s ok on desktop.

Ok, hmm, and no problem in the console? What if you isolate it to a minimal project with only the spine model? Same problem then? Perhaps you could share your project with @sven or @Johan_Beck-Noren?

It’s hard to say anything without logs or a repro case. If you could create a minimal example project with the issue and share the project with me at johan.beck-noren@king.com I could take a look.

1 Like

I make a minimal project, clone it at:

git@github.com:lovebirdsx/defold_bug.git

1 Like

Thanks! @Johan_Beck-Noren can you take a look?

Great, thanks!

The issue seems to be with bundling rather than android specific. When launching the game directly from editor2 a different pipeline is used to process resources than when bundling (if you bundle for desktop you will see the same issue as you do in android). So the bug causing the issue is in the bundling step (e.g. bob.jar).

No workaround so far, though it should work to target the device from editor2 and running the game that way for now.

I had a chance to look more closely at the code you posted;

local combo_node = gui.get_node('combo')
gui.set_enabled(combo_node, true)			
gui.set_spine_scene(combo_node, hash('combo3'))
gui.set_spine_skin(combo_node, hash("default")) -- [1]
gui.set_spine_cursor(combo_node, 1) -- [2]
gui.play_spine_anim(combo_node, 'animation', gui.PLAYBACK_ONCE_FORWARD)

[1]: There is no need to set the default skin it will be set implicitly when setting the spine scene. Just remove that line and it should work as intended. I agree though that it should work to set the default skin explicitly like this, added ticket DEF-3070.

[2]: Setting the spine cursor to 1 will place the cursor at the end of the animation, luckily enough the call to gui.set_spine_cursor only works on the currently playing animation. Since there is no animation playing when it is called it won’t have any effect. This line can also be removed.

Side note: If you want to offset the starting position for the cursor, it can be passed as an argument to gui.play_spine_anim instead, see docs: https://www.defold.com/ref/gui/#gui.play_spine_anim:node-animation_id-playback--play_properties---complete_function-

3 Likes

Thanks for your advice. And wish the bug be fixed as quick as possible.

1 Like