0
こんにちは私は場所に変わっているthatsに触れ、弾丸を撃つしようとしています これまでのところ問題はありませんが、私が触れた方向に向いていない 注記:私はそれが回ったが、私が触れた特定の場所にはないことを伝えるのを忘れてしまった。 私はこのソースに見えたが、彼らはここで http://www.cocos2d-iphone.org/forum/topic/1823 http://stackoverflow.com/questions/3018688/rotating-and-moving-a-uiimageview-cocoatouchUIImageViewに角度回転をさせるが、それは何を期待して作るのではない
が回転しない私のコードで助けたdidntの。私は何が欠けていますか?
-(void)update:(UITapGestureRecognizer *)recognizer
{
double dx,dy;
CGPoint location = [recognizer locationInView:self.view];
turret.transform=CGAffineTransformIdentity;
bullet.transform=CGAffineTransformIdentity;
bullet.center=turret.center;
if (location.x < 160)
{
dx=turret.center.x-location.x;
dy=turret.center.y-location.y;
//if user touched greater than 180
}
else if (location.x > 160)
{
dx=location.x-turret.center.x;
dy=location.y-turret.center.y;
//if user touched less than 180
}
CGAffineTransform transform = CGAffineTransformMakeRotation((atan2(dy,dx)*180/M_PI));
NSLog(@"%f",atan2(dy,dx)*180/M_PI);
bullet.transform=transform;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
turret.transform = transform;
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.5];
bullet.center=location;
[UIView commitAnimations];
実際には何が起こるのですか?それはまったく回転しますか、もしそうなら、どのように回転しますか? – jrtc27