Animation gets in the way :(

I am having a heck of a time with animation in an iOS program (Swift). The animations work, but the rest of the program continues while the animation is happening. I tried putting a counter in that increments when an animation starts, and decrements when it ends… [note they are multiple animations happening at the same time].

The problem is if while an animation is happening, a logic function executes and it needs certain things to be in a given state, and they aren’t then wrong things occur. Note the proper state is met when some of the animations complete.

For example. A playing card is moving across the screen, and the code checks if that card is at a certain location… but it isn’t YET,

Basiclly I need to block the main run loop, while the animation threads are running

I have zero knowledge in Swift but in Xojo I would do it with a delegate that invokes the logic once the animation completes. This is how do it in my football manager game.

the problem is that I need to block the main thread while an animation is running… this shouldn’t be a visual problem since the animations only take a second or less…

seems using DISPATCHGROUPS solved it

Just out of curiosity: What kind of animation are you using? Shouldn’t a QuartzCore Animation give you the ability to start a group animation and have a block execute when it finished?
Blocking the main thread sounds a bit harsh to me.

1 Like

the problem was trying to know when dozens of animations finished… DispatchGroup does this