Я пытаюсь обнаружить касание, которое началось с n touch end на определенной части экрана. У меня есть Spider as Sprite, и я меняю направление лица на touchbegan и touchhend. и я хочу получить прикосновение только от моего паук.Получить прикосновения на экране в iPhone Cocos2d
- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
//[self ccTouchesMoved:touches withEvent:event];
UITouch *touch = [touches anyObject];
startTouchPoint = [touch locationInView: [touch view]];
//location = [[CCDirector sharedDirector] convertToGL: location];
CCLOG(@"Location of Touch %@",NSStringFromCGPoint(startTouchPoint));
}
- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint endlocation = [touch locationInView: [touch view]];
if(startTouchPoint.x != endlocation.x && startTouchPoint.y != endlocation.y) {
CGPoint touchPoint = [touch locationInView: [touch view]];
touchPoint = [[CCDirector sharedDirector] convertToGL:touchPoint];
[self calcAngleAndRotateObjectStartingAtPoint:sprite_Spider.position endingAtPoint:touchPoint];
}
}
Это мой паук, и я хочу, чтобы получить связь только между этими красными линиями. Как я могу это достичь.
но как я обнаруживаю вкладку между этими линиями? – Zohaib
Напишите функцию, в которой calcualtes вернет tyes или нет, в зависимости от того, что вы нажимаете posiiton.You можете прочитать точку жестов, а из изображения вы знаете координаты строк –
Эти строки не являются статическими. они будут меняться. – Zohaib