我在嘗試觸碰問題時遇到了一些問題,以響應多點觸控。多點觸控開始
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSSet *allTouches = [event allTouches];
for (UITouch *touch in allTouches)
{
CGPoint location = [touch locationInView:touch.view];
if(CGRectContainsPoint(snare.frame, location) && lastButton != snare) {
//Swap Image
snareImg.image = snareImgDown;
[self performSelector:@selector(swapBack) withObject:nil afterDelay:0.1];
//Play Sound
NSString *path = [[NSBundle mainBundle] pathForResource:@"snare"
ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
, &soundID);
AudioServicesPlaySystemSound (soundID);
//
lastButton = snare;
}
else if(CGRectContainsPoint(hiHat.frame, location) && lastButton != hiHat) {
//Play Sound
NSString *path = [[NSBundle mainBundle] pathForResource:@"hi_hat"
ofType:@"wav"];
SystemSoundID soundID;
AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path]
, &soundID);
AudioServicesPlaySystemSound (soundID);
//
lastButton = hiHat;
}
,我不知道如何得到它的設置,這樣它會以多點觸摸做出反應,現在的touchesBegan只有1點按工作。我知道那裏有我喜歡的東西(UITOuch * t),我不記得它是如何工作的。
任何人都知道該怎麼做?
您是否在視圖中設置了'multipleTouchEnabled = YES'? – 2010-06-17 14:38:38