我試圖爲iPad構建一個基本的Jigsaw應用程序,但我對於Objective C和xcode非常新,這意味着這是我第一次在完全正常工作的應用程序中使用。如何檢查圖像的位置,並在iOS中嵌入
我一直在網上學習一些教程,並已經建立了一個非常基本的三個圖像拼圖,並已成功設法讓這個運行。不過,我希望能夠在用戶拖動正確的區域並顯示動畫或聲音時將圖像捕捉到位。
我有點迷路了,我知道我需要指定每個拼圖的x和y座標然而,如果這是正確的位置,然後觸發一個動作,如動畫和聲音?
這是到目前爲止我的代碼
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches]anyObject];
CGPoint touchLocation = [touch
locationInView:self.view];
if ([touch view] == image1){
image1.center = touchLocation;
NSLog(@"Touch x : %f y : %f", touchLocation.x, touchLocation.y);
}
else if ([touch view] == image2){
image2.center = touchLocation;
NSLog(@"Touch x : %f y : %f", touchLocation.x, touchLocation.y);
}
else if ([touch view] == image3){
image3.center = touchLocation;
NSLog(@"Touch x : %f y : %f", touchLocation.x, touchLocation.y);
}
}
正如你所看到的IM登錄電子x和不過ÿ即時通訊不能確定如何與這個
由於與編輯的一點點,玩耍取得了這項工作完美! – user3246508
不客氣:) – MAB