Compound animation [SOLVED]

I’m trying to make a cyclic animation of 2 attacks by pressing one button. I thought about doing this using complete_function, but I don’t understand how it works. Or is it easier to do it using a timer?

Yes, the complete function can be used to play one animation after the other:

-- play the first animation
sprite.play_flipbook("#sprite", "first_anim", function()
    -- play the second animation when the first has finished
    sprite.play_flipbook("#sprite", "second_anim")
end)

oh it was so easy! Is it possible to add some code to this function? I saw in the API something about actions in a specific animation frame, but I also didn’t understand how to work with it

How do you mean?

something like that

`local function attack(self)
	-- play the first animation
	sprite.play_flipbook("#sprite", anim_strike, function()
		-- play the second animation when the first has finished
		sprite.play_flipbook("#sprite", anim_strike2, function()
			factory.create("#factory")
			sprite.play_flipbook("#sprite", anim_idle)
	end)
	end)`

i check and it’s works. big thanks!!!

3 Likes