0

肯定是错误的anyTouchEndedThisFrame我现在已经尝试过所有事情,它只会在我移动手指时计算结束的触摸,如果我在同一个位置触摸并松开它不会计算它,如果我错了请纠正我

-(void) moveObjectToNewPosition:(KKInput *)input
{
    if (input.anyTouchEndedThisFrame) {
        [self touchesEnded:[input locationOfAnyTouchInPhase:KKTouchPhaseAny]];

    } if (input.anyTouchBeganThisFrame) {
        [self touchesBegan:[input locationOfAnyTouchInPhase:KKTouchPhaseBegan]];
    }
4

1 回答 1

1

它甚至对我都没有用,你应该实现这个非常简单易用的方法

-(void) ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

    NSSet *allTouches = [event allTouches];
    UITouch * touch = [[allTouches allObjects] objectAtIndex:0];

    CGPoint location = [touch locationInView: [touch view]];
    location = [[CCDirector sharedDirector] convertToGL:location];

}

-(void) ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

}

-(void) ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {

}

并添加到您的初始化中:

[self setTouchEnabled:YES];
于 2013-05-13T11:59:26.613 回答