开发者

CAKeyframeAnimation and sprite sheet animation problem

开发者 https://www.devze.com 2023-03-13 04:59 出处:网络
I have a CAKeyframeAnimation of a sprite sheet\'s contentsRects property to show an animation in a CALayer. Everything works most of the time, but occasionally I see a wrong part of sprite sheet for a

I have a CAKeyframeAnimation of a sprite sheet's contentsRects property to show an animation in a CALayer. Everything works most of the time, but occasionally I see a wrong part of sprite sheet for a one frame. CAKeyframeAnimation is set to discrete mode and all the coordinates are checked. Seems to me that once in a while CAKeyframeAnimation misses a keyframe and shows me just a center piece of my sprite sheet instead of a piece that it suppose to cut out based 开发者_JAVA技巧on provided array of contensRects. How to fix the above? Also on the same topic how to debug CAKeyframeAnimation in general and find out what's going on?

thanks!


to fix it I've wrapped my animation in CATransaction and temporarily disabled all layer actions:

[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; // we need to disable all layer actions temporarily

.............. the rest of animation code ...............

[CATransaction commit];

thank you Apple's documentation!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号