Yuchen Wang
Yuchen Wang

Reputation: 1722

How to detect a core animation is skipped / failed to start

In my game, I have a series of core animation running one after another within split of a second. At the end of the animations, a method is invoked to triggered (animationDidStop:) some important logic.

Usually this works well. However, occasionally, specially on slower device such as iPhone 3G or iPhone 2, one of the animations is skipped (or failed to start) due to timing issue (too much stuff running and the CPU can't catchup). I am fine with skipping animations, but the problem is, my method is not invoked either. It will be nice if such skipping can be detected.

Anybody knows how to detect the case when a core animation is skipped/failed to start?

thanks.

Upvotes: 4

Views: 248

Answers (2)

objectivecdeveloper
objectivecdeveloper

Reputation: 1050

You need to use 2 things for that

- NSTimer* timer

- BOOL isAnimationCompleted

1) Start a timer "timer" of same time as animation time.

2) set "isAnimationCompleted = TRUE" in (animationDidStop:) method

3) after "timer" ticks check for the "isAnimationCompleted" variable

if(!isAnimationCompleted)

[self callMethodMannually];

Upvotes: 1

gdawg
gdawg

Reputation: 721

I'm sure there's a better option I don't see but you could always save the state in some variable then use an NSTimer to fire off a task which later checks that state.

Hopefully someone else comes up with something a bit less hacky for you!

Upvotes: 0

Related Questions