Flipbook animation not fully completing

hello I am trying to make a combat system however the attacking animation isn’t completing and therefore won’t trigger the flipbook_done portion, I am confused as to why it will not fully complete

<function play_animation(self, anim)

if self.anim ~= anim then
	sprite.play_flipbook("#Player 1", anim, flipbook_done)
	self.anim = anim
end

end

Is your animation looping? Your animation won’t complete if it’s looping, you need to use one of the “once” options in your atlas or tile source.

I have already done that,however i am still running into the same problem

DEBUG:SCRIPT: hash: [idle]
DEBUG:SCRIPT: hash: [attack(ground)]
DEBUG:SCRIPT: true
DEBUG:SCRIPT: hash: [idle]
DEBUG:SCRIPT: hash: [attack(ground)]
DEBUG:SCRIPT: true
DEBUG:SCRIPT: hash: [idle]
DEBUG:SCRIPT: hash: [attack(ground)]
<

these are my logs where “hash:[]” is the message id and true is when Attacking == true, and Attacking becomes false when the animation finishes

<
local function flipbook_done(self)

if self.anim == anim_attack then
	self.Attacking = false
end

end

Can you share your entire script please?

sorry I found the issue it was that in the update function the update_animation function was being called meaning that the animation was being updated every second and not finishing

2 Likes

Just mentioning that this discussion helped me solve a similar problem.

In the War Battles tutorial, when I moved past the initial setup and did the extra suggestions, I had missile-tank explosions not finishing. The missile would hit the tank and then the explosion wouldn’t finish for either the missile or the tank.

Notably, the score would count up like crazy.

Turns out it was the collisions of the tank & missile. They were continuing to happen during the explosion animations and caused the animations to not finish (sort of like the update_animation problem here).

Disabling the collision object on the rocket immediately solved it.

function on_message(self, message_id, message, sender)
	if message_id == hash("animation_done") then           
		go.delete()                                        
	elseif message_id == hash("collision_response") then
		explode(self)
		msg.post("#collisionobject", "disable")   -- Disable here ends the collision overloads
		msg.post(message.other_id, "explode")
		msg.post("/gui#ui", "add_score", {score = 100})					
	end 
end
1 Like