i'd like to change sounds when tapping on an image and drag another image over several others.
it is not working properly: the "MoveImage" is not dragable, the tapping is working outside the "TouchImage" and the sounds do not change when tapping on it.
(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if(((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_1.frame)))) {
[sound_E play];
}
if (((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_2.frame)))) {
[sound_F play];
}
if (((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_3.frame)))) {
[sound_D play];
}
if (((CGRectContainsPoint(myTouchImage.frame, location)), (CGRectIntersectsRect(myMoveImage.frame,myImage_4.frame)))) {
[sound_Dis play];
}
}
(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
if (CGRectContainsPoint(myMoveImage.frame, location)){
CGPoint yLocation = CGPointMake(myMoveImage.center.x,location.y);
myMoveImage.center = yLocation;
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_1.frame)) {
E_NOTE.text = @"E";
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_2.frame)) {
F_NOTE.text = @"F";
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_3.frame)) {
D_NOTE.text = @"D";
}
if(CGRectIntersectsRect(myMoveImage.frame,myImage_4.frame)) {
Dis_NOTE.text = @"D#";
}
}