У меня есть несколько изображений, которые я могу перемещать на экране iphones с помощью мультитач. Дело в том, что я хочу разделить их на две «команды», «команду» изображений, которые я перемещаю внутри области по своему выбору, и «команду», которую я могу перемещать по всему экрану.
Мой вопрос заключается в том, как использовать сенсорные методы (touchesbegan, touchesended, touchesmoved) для обеих обеих команд «uimage» и их cgpoints без пересечения cgpoints обеих «команд» и неправильного расположения uijmages на неправильных позициях экран. 1-я «команда» использует методы touch-began, touchesmoved и touchesended. 2-я «команда» использует только метод 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]];
}
}