每次与另一个图像碰撞时缩放图像
这是我的代码:
-(void)collision{
if(CGRectIntersectsRect(imageView.frame,centre.frame)){
imageView.alpha=0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
centre.transform=CGAffineTransformMakeScale(1.3, 1.3);
[UIView commitAnimations];
}
}
当 imageView 与中心中心碰撞时变得更大。 我的问题是,当“imageView”第二次与“center”碰撞时,动画不起作用。我想让中心每次 imageView 与中心碰撞时变得越来越大,但它只变大一次。抱歉我的英语我是法国人:/请问我该如何解决这个问题?
here is my code :
-(void)collision{
if(CGRectIntersectsRect(imageView.frame,centre.frame)){
imageView.alpha=0;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0f];
centre.transform=CGAffineTransformMakeScale(1.3, 1.3);
[UIView commitAnimations];
}
}
When imageView collide with centre centre become bigger.
my problem is that when "imageView" collide with "centre" a second time the animation doesn't work. I want to make centre bigger and bigger and bigger every time imageView collide with center, but it become bigger just one time . Sorry for my english I'm french :/ How can I solve this please ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的视图没有第二次缩放的原因是您每次都对其应用相同的变换 - 您每次都需要更改应用的变换:
The reason your view is not scaled second time is that you apply the same transform to it every time - you need to change applied transformation every time:
可能是之后没有应用秤。尝试每次增加比例值。声明一个
float
来跟踪对象的比例。然后,在每次碰撞期间,在执行CGAffineTransformMakeScale(scale,scale)
之前执行以下操作:
It may be that the scale is not applied after. Try incrementing the scale value each time. Declare a
float
to keep track of the object's scale. Then, during each collision, before you execute theCGAffineTransformMakeScale(scale, scale)
do this:Example