1
我有幾個使用多點觸摸可以在iphonescreen上移動的uiimages。問題是我想要將它們分成兩個「團隊」,一個是我選擇的區域內的一個「團隊」,一個是我可以在整個屏幕上移動的「團隊」。關於多點觸摸的問題
我的問題是如何使用觸摸方法(touchesbegan,touchesended,touchesmoved)爲兩個uiimage「團隊」和他們的cgpoints沒有來自兩個「團隊」的cgpoints相互交叉和給錯誤的uiimages錯誤的位置上屏幕。第一個「團隊」使用touchesbegan,touchesmoved和touchesended方法。第二個「團隊」只使用touchesended方法。
這是我的代碼。我希望2「團隊」交叉彼此在touchesended方法
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
//1st team
for(UITouch *touch in touches){
// Send to the dispatch method, which will make sure the appropriate subview is acted upon
[self getRubyAtPoint:[touch locationInView:self.view]forEvent: nil];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"touchesEnded");
//1st team
// Enumerates through all touch object
for (UITouch *touch in touches) {
// Sends to the dispatch method, which will make sure the appropriate subview is acted upon
[self dispatchTouchEndEvent:[touch view] toPosition:[touch locationInView:self.view]];
}
//2nd team
UITouch *touch = [touches anyObject];
CGPoint currentTouch = [touch locationInView:self.view];
[self getPieceAtPoint:currentTouch];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
//1st team
NSLog(@"touchesMoved");
// Enumerates through all touch objects
for (UITouch *touch in touches) {
// Send to the dispatch method, which will make sure the appropriate subview is acted upon
[self dispatchTouchEvent:[touch view] toPosition:[touch locationInView:self.view]];
}
}
正是...我要上第一隊的dispatchTouchEndEvent只有行爲和getPieceAtPoint到2號球隊在touchesended方法僅行爲。一個標籤?好吧,這聽起來像個好主意。我會試試看,並讓你知道。 thanx :) – iphonedevonthemake 2011-04-13 03:20:25
它工作正常! thanx:D – iphonedevonthemake 2011-04-13 05:57:06