【问题标题】:CAKeyframeAnimation and sprite sheet animation problemCAKeyframeAnimation 和 sprite sheet 动画问题
【发布时间】:2011-06-14 21:55:09
【问题描述】:
我有一个精灵表 contentsRects 属性的 CAKeyframeAnimation 来在 CALayer 中显示动画。大部分时间一切正常,但偶尔我会看到一帧的精灵表的错误部分。 CAKeyframeAnimation 设置为离散模式并检查所有坐标。在我看来,CAKeyframeAnimation 偶尔会错过一个关键帧,并且只显示我的精灵表的中心部分,而不是它假设根据提供的 contensRects 数组剪切的部分。如何解决以上问题?同样在同一主题上,如何调试 CAKeyframeAnimation 并找出发生了什么?
谢谢!
【问题讨论】:
标签:
ipad
debugging
animation
sprite
cakeyframeanimation
【解决方案1】:
为了解决这个问题,我将动画包装在 CATransaction 中并暂时禁用了所有图层操作:
[CATransaction begin];
[CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; // we need to disable all layer actions temporarily
.............. the rest of animation code ...............
[CATransaction commit];
感谢 Apple 的文档!