Animation in the foreground?

I see that there’s an easy way to do smooth animation using intervals, but when you start an interval, the start function returns immediately and the animation happens in the background. Is there an easy way to animate objects and wait for them to move before continuing the execution of my program?

Can I set up an interval to play for X seconds, start it, and then essentially sleep for X seconds while the interval plays? I’ve tried Python’s time.sleep function, but that doesn’t work. I’m guessing that’s because the Panda3D main loop can’t run while it’s sleeping.

The reason I ask is because I’m writing an turn-based game, and I’d like to animate the movements of the pieces, but (for instance) I don’t want the player’s turn to start while the CPU’s piece is still moving to its new position.

When the CPU opponent starts it’s turn lock the player’s turn from starting. Use a sequence to chain the lerpinterval for the piece movement and a Func() to unlock the player’s turn. This will make it so that the animation plays before the player can move.

Ok, thanks! That sounds a lot like what I was thinking of doing, but I was hoping there was an easier way that hadn’t occurred to me.