我正在尝试检测屏幕特定部分上的触摸开始和触摸结束。我有一个作为 Sprite 的蜘蛛,我通过 touchbegan 和 touchend 改变它的面方向。我只想从我的蜘蛛前面接触。
- (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];
}
}
这是我的蜘蛛,我只想在那些红线之间接触。我怎样才能实现它。