# Complete\_function not calling if the same animation starts immediately

**URL:** <https://forum.defold.com/t/complete-function-not-calling-if-the-same-animation-starts-immediately/74957>\
**Category:** Bugs\
**Created:** [November 14, 2023, 8:37pm UTC](https://forum.defold.com/t/complete-function-not-calling-if-the-same-animation-starts-immediately/74957 "2023-11-14T20:37:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thawri](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/thawri/32/24046_2.png) [@thawri](https://forum.defold.com/u/thawri)\
**Post date:** [November 14, 2023, 8:37pm UTC](https://forum.defold.com/t/complete-function-not-calling-if-the-same-animation-starts-immediately/74957/1 "2023-11-14T20:37:49Z")

</div>

I want to simulate card-flipping animation using this script:

```lua
local function rotateCard()
	go.animate(".", "scale.x", go.PLAYBACK_ONCE_FORWARD, 0, go.EASING_INCIRC, 0.4, 0, function ()
		print("flipped")
		msg.post("#icon", "enable")
	end)
	go.animate(".", "scale.x", go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_OUTCIRC, 0.3, 0.45)
end

```

It works fine, but I must play the second animation with more delay.  
I want to play the second animation immediately after the first animation is done i.e. with a 0.4-second delay. but in this case complete\_function not calling. I must play the second animation at least 0.05 seconds later to "complete\_function " work.

---

<div class="post-metadata">

**Author:** ![roccosaienz](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/roccosaienz/32/19991_2.png) [@roccosaienz](https://forum.defold.com/u/roccosaienz)\
**Post date:** [November 14, 2023, 8:56pm UTC](https://forum.defold.com/t/complete-function-not-calling-if-the-same-animation-starts-immediately/74957/2 "2023-11-14T20:56:16Z")

</div>

Have you tried:

```lua
    local function rotateCard()
        	go.animate(".", "scale.x", go.PLAYBACK_ONCE_FORWARD, 0, go.EASING_INCIRC, 0.4, 0,
            function ()
        		print("flipped")
        	    msg.post("#icon", "enable")
        	    go.animate(".", "scale.x", go.PLAYBACK_ONCE_FORWARD, 1, go.EASING_OUTCIRC, 0.3)
        	end)
    end

```

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [November 14, 2023, 11:02pm UTC](https://forum.defold.com/t/complete-function-not-calling-if-the-same-animation-starts-immediately/74957/3 "2023-11-14T23:02:45Z")

</div>

You cannot have more than one animation on a property (e.g “scale.x”) at the same time.  
So, you’ll cancel the first animation and replace it with the second one.  
This is by design.

What @roccosaienz suggested is our recommended approach to chain multiple animations together, by using the complete-function.
