Go animation return function

Hello all.

Last parameter in go.animation it callback function. In my project sometimes it callback function not call. I think it because animation not change position object. I think right? It happenend when GO start next animation very fast and previous animation not finished. May be you know good method resolve problem.

The callback function will only be called if the animation is allowed to finish before you trigger a new animation. An animation that is cancelled (go.cancel_animation()) or replaced by a new animation (go.animate()) will not trigger the callback. And obviously an animation that has a playback of go.PLAYBACK_LOOP_* will never finish and invoke the callback function either.

Thank you.

I have fast change incoming messages for animation parameters and go.animation() - replaced and not finished. I think about change logic, but it may be problem.

I have ran into similar problems at a few occasions where I’ve had multiple animations running on top of each other. Try checking for that.

Yeah I have same.

Logic example:
Every 2-5 sec recieve incoming message, after receive - start animation. If previous animation not finished, next logic not working :frowning:

function y_done(self, url, property)		
	local target_x = 13
	for i=1,10 do							
		if i < 10 then			
			go.animate("/psychoState/psychoStateBarSingle"..tostring(i), "position.x", go.PLAYBACK_ONCE_FORWARD, target_x, go.EASING_INOUTBACK, 1, 0)																			
		else
			go.animate("/psychoState/psychoStateBarSingle"..tostring(i), "position.x", go.PLAYBACK_ONCE_FORWARD, target_x, go.EASING_INOUTBACK, 1, 0, x_done)			
		end	
		go.animate("/psychoState/psychoStateBarSingleEmpty"..tostring(i), "position.x", go.PLAYBACK_ONCE_FORWARD, target_x, go.EASING_INOUTBACK, 1, 0)		
	end			
end	

function x_done(self, url, property)						
--something code
end

function on_message(self, message_id, message, sender)
if message_id == hash("change_state") then
		self.newChange = true		
		if type(message.stateParamsChange) == "table" then			
			self.stateParamsChange[#self.stateParamsChange+1] = message.stateParamsChange
		else
			self.stateParamsChange = {}
		end
       go.animate("/psychoState/psychoPortraitState", "position.y", go.PLAYBACK_ONCE_FORWARD, 186, go.EASING_INOUTBACK, 0.5, 0, y_done)
	end
end

Animation in on_mesage function work good(it ended first) and y_done function ended everytime, but animation in x_done function sometimes not ended and x_done not executed :frowning: