【问题标题】:Animating an Image动画图像
【发布时间】:2010-04-13 11:55:56
【问题描述】:

我正在创建一个游戏,因为我想使用一些动画,但我是动画新手。 我想创建一个图像,一旦我点击imageview,图像应该以弹跳的方式出现,就好像它是一个球一样,所以可以这样做吗???该图像是为游戏预定义的。它必须在触摸开始事件发生后出现,有人可以帮我吗??? 问候 病毒式传播。

【问题讨论】:

  • 这个问题的答案非常复杂。您需要阅读计算机动画或游戏编程方面的知识。
  • 如果你能想象到那么它几乎肯定是可以编码的,你试过什么编码?
  • 我没有添加任何动画代码,现在我一触摸图像视图就会显示简单的值,但我想要一些不同的图像动画。

标签: iphone objective-c iphone-sdk-3.0


【解决方案1】:

你可以做类似的事情

imageview = [[[UIImageView alloc] initWithFrame:CGRectMake(x,y,w,h)]autorelease];
    imageview.image = [[UIImage imageNamed: [NSString stringWithString:name]]autorelease];
    [self.view addSubview:imageview];
    imageview.frame = CGRectMake(imageview.frame.origin.x, (imageview.frame.origin.y), imageview.frame.size.width, imageview.frame.size.height);
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDelegate:self];
    //[UIView setAnimationWillStartSelector:@selector(Transform2)];


    [UIView setAnimationDuration:k_AnimateTime];

    [UIView setAnimationBeginsFromCurrentState:YES];
    //[UIView setAnimationDidStopSelector:@selector(increaseCount)];
    imageview.frame = CGRectMake(imageview.frame.origin.x - Ex, (imageview.frame.origin.y - Ey), imageview.frame.size.width, imageview.frame.size.height);
    [UIView commitAnimations];

这会将您的图像从一个坐标移动到另一个坐标动画...设置适当的坐标以使其看起来像弹跳效果...

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-04-14
    • 2014-02-22
    • 2013-04-30
    • 2014-08-31
    • 2013-05-26
    • 2013-12-16
    • 1970-01-01
    相关资源
    最近更新 更多