Glitch in GUI Spine. First animation play (DEF-3384)

Got the next glitch on spine gui animations:
GUI%20spine%20bug

Im trying to play spine animation on cloned spine gui component.
The example project: https://drive.google.com/open?id=1jH_nKBkPqf-oPyezqhxwPGzDjUQMOKG6

And I have some questions about my example code:

function init(self)
	gui.set_enabled(gui.get_node("explo"), false)
	self.nodes = {}
	
	for i = 1, 100 do
		self.nodes[i] = gui.clone(gui.get_node("explo"))
		-- CASE1
		--gui.play_spine_anim(self.nodes[i], "Particle_explosion", gui.PLAYBACK_ONCE_FORWARD)
	end
	self.index = 1
end

function update(self, dt)
	self.t = (self.t or 1) - dt

	if self.t < 0 then
		self.t = 1
		local node = self.nodes[self.index]
		self.index = self.index + 1


		-- CASE 2
		--timer.delay(0.0001, false, function()
			gui.set_enabled(node, true)
			gui.play_spine_anim(node, "Particle_explosion", gui.PLAYBACK_ONCE_FORWARD, {}, function()
				gui.delete_node(node)
			end)
		--end)
	end
end

If i run this code, i got the bug
If i uncomment CASE1 (preplay animation) all will be ok
If i uncomment CASE2 (enable node and play in timer callback) all will be ok

What it can be? Why it is works ok with timer? After node cloning and playing about 1 second. Cant understand why timer affected on this.

Without cloning its glitched too on first animation play

What happens is that the spines “initial” state is shown for one frame. It works with preplaying it because then you are skipping the initial state.
Why it works with the timer I can only guess, I guess it delays playing the spine and therefore it somehow makes the spine skip the “initial” frame.

You can fix this by having a better initial state for your spine. We usually have a “empty idle” or something similar and set that as the default animation.

We have had quite a bit of problem with this (most recently today actually) and it didn’t use to do this. I think it might have started to happen at 1.2.127 or even 1.2.123 can’t remember exactly. I remember it made me go trough a lot of spine scenes and set a better “default animation” so that we wouldn’t get this little glitch everywhere.

Update:

We did some further testing and this does’t seem to be entirely true (at least for GUI). We have a spine that is playing an animation that is starting of screen, and we still see a frame of it in a “setup” stage or something.

The only thing that seemed to help our case is to have it disabled in the init and when playing the animation doing

timer.delay(0.0, false, function()
    gui.set_enabled(self.spine, true)
end)
gui.play_spine_anim(self.spine, "Particle_explosion", gui.PLAYBACK_ONCE_FORWARD)

Enabling the spine inside a timer even with a delay of 0.0 works, placing the enable outside the timer doesn’t work.

I even tried to set the spines “setup” state to be outside the view but wierdly enough we still get the error.

2 Likes

Has this been reported before? I don’t recall hearing about it until now.

What is the default animation set to on the component/spine node? I would suspect that at the time of it spawning it should display the first frame of the animation that is currently “playing”, if not it certainly sounds like a bug.

You can see the example in the first message
First frame of the initial spine animation will be in any case

It seems that the default animation is not correctly set for cloned spine nodes, adding an issue for this: DEF-3384

2 Likes

In example, if i will play original node, will be the same glitch
Seems, it is not only problem of cloned nodes

But in the project you shared, there was no default animation set on the node?

Yea, correct
Default animation, as i know, start to play after node init. So it is seems like the CASE1 from the code.
If I play animations in the first second after init (with default animation), there is will be glitch too

I will double check on Monday, but I am quite sure the behavior we saw didn’t change if we had a default animation set.

1 Like