那么这里是我的问题: 我有两个图像:flakeImage和ViewToRotate。我想要的是,如果flakeImage触及ViewToRotate,ViewToRotate.alpha = 0.5;但是当FlakeImage出现在屏幕上时ViewToRotate.alpha = 0.5;不用碰它。我认为这是一个问题,我的看法我东阳有:两个图像碰撞的问题
UIImageView* flakeView = [[UIImageView alloc] initWithImage:flakeImage];
这里是代码:
UIImageView* flakeView = [[UIImageView alloc] initWithImage:flakeImage];
// use the random() function to randomize up our flake attributes
int startY = round(random() % 320);
// set the flake start position
flakeView.center = CGPointMake(490, startY);
flakeView.alpha = 1;
// put the flake in our main view
[self.view addSubview:flakeView];
[UIView beginAnimations:nil context:flakeView];
// set up how fast the flake will fall
[UIView setAnimationDuration:7 ];
// set the postion where flake will move to
flakeView.center = viewToRotate.center;
// set a stop callback so we can cleanup the flake when it reaches the
// end of its animation
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
我怎样才能解决这个问题吗? 如果有人能帮助我,这将是非常酷。
当动画结束时,将alpha设置为0.5就足够了吗?或者你需要真正的碰撞代码? – 2011-05-08 08:46:22
我需要真实的碰撞代码,但是当图像(flakeView)出现在屏幕上而没有碰撞另一个is.alpha = 0.5; – 2011-05-08 12:56:09
嗯我仍然不确定你真的需要什么。所以你有一个片,也许是一个雪片?它从一个随机的高度(startY)开始并下降,或者去到viewToRotate的位置,对吗?那么为什么当动画的目标是让片状物位于另一个视图的相同位置时,您需要碰撞检测?到目前为止,这是关于职位,阿尔法与它有什么关系?当薄片碰到它的最终目的地时,它应该变成半透明的?请帮助我理解。 – 2011-05-08 16:29:21