排序 UIImageView 帧动画和CG变换动画

发布于 2024-08-09 04:45:19 字数 886 浏览 3 评论 0原文

我需要有关一些动画排序策略的帮助。

我对 UIImageView 进行了子类化,以便我可以在图像上编写一些自定义动画操作。我实现了一些方法,用作可以在图像上调用的操作 示例:

-(void)rotateAnim; //rotates the image by a few degrees using a CGAffine Transform

-(void)numbersFlashAnim; //uses the UIImageVew.animationImages array for a 14 frame animation.

-(void)moveLeftAnim; //uses another CGAffine Transform to change the imageView's position.

在我的 viewDidLoad 方法中,我创建了 UIImageView 子类的一个实例。有哪些方法可以按顺序调用这些动画?

我正在考虑使用 NSTimer 来处理动画,但不确定是否可以编写 NSTimer 对象来处理多个方法调用。

示例:

[imageView rotateAnim]; //when this animation is done, I want to call:
[imageView numbersFlashAnim];

我看到了几个有关使用 NSTimer 的问题,但没有一个与此问题具体相关。注意:我看到苹果网站上的开发文档还建议在某些情况下使用performSelector:withObject:afterDelay:,但我想知道这是否会提供足够的灵活性。

另外,我已经研究过 Cocos2d 框架,虽然我可以使用他们的方法〜(序列操作:等),但我选择使用 UIKit/Foundation 等来解决这个问题。

I'd like help on some strategies to sequence some animations.

I subclassed UIImageView so that I could write some custom animation actions on an image. I implemented a few methods to be used as actions that I could call on my image
example:

-(void)rotateAnim; //rotates the image by a few degrees using a CGAffine Transform

-(void)numbersFlashAnim; //uses the UIImageVew.animationImages array for a 14 frame animation.

-(void)moveLeftAnim; //uses another CGAffine Transform to change the imageView's position.

In my viewDidLoad method I create an instance of my UIImageView subclass. What ways exist to call these animations in sequence?

I was thinking about using an NSTimer to handle the animations, but wasn't sure if you could write an NSTimer object to handle multiple method calls.

example:

[imageView rotateAnim]; //when this animation is done, I want to call:
[imageView numbersFlashAnim];

I've seen several questions regarding the use of an NSTimer, but none that specifically relate to this problem. Note: I saw that the dev docs on apple's site also recommend the use of the performSelector:withObject:afterDelay: in some cases but was wondering if that would offer enough flexibility.

Additionally, I've already taken a look at the Cocos2d framework, and although I can use their methods ~(Sequence actions: etc, ) I'm choosing to solve this problem with UIKit/Foundation, etc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽梦忆笙歌 2024-08-16 04:45:19

你使用动画吗?我的意思是你可以在里面旋转你的图像
[UIView beginAnimations:(NSString *)animationID context:(void *)context] 块。您可以在其中添加一个委托方法,该方法将在当前动画结束后调用。在那里你可以调用你的号码FlashAnim。
(抱歉我的英语不好;-))

Do you use animation? I mean you can rotate your image inside
[UIView beginAnimations:(NSString *)animationID context:(void *)context] block. There you can add a delegate method that will be called after current animation ends. And there you can call your numbersFlashAnim.
(Sorry for my english ;-) )

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文