Asm*_*ita 6 iphone objective-c ios
我有一个查询.我正在尝试开发像iOS中的Abacus这样的游戏.我想在iOS中水平地将四个图像从一个位置移动到另一个位置.任何人都可以帮助我,请问我在iOS中如何做到这一点.我参考这个链接如何使用动画在iphone应用程序中将对象从一个地方移动到另一个地方 但是使用这个我能够水平移动一个图像我想移动四个图像我是如何做到这一点的.
这是我尝试过的:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
CGPoint loc = [touch locationInView:self.view];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2.0];
CGRect rect = CGRectMake(loc.x, _img.frame.origin.y, _img.frame.size.height, _img.frame.size.width);
[_img setFrame:rect];
[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
308 次 |
| 最近记录: |