Kobold2d: KKInput anyTouchEndedThisFrame

早过忘川 提交于 2019-12-12 03:52:49

问题


The anyTouchEndedThisFrame must be buggy I´ve tried about everything now, and it will only reckonize a touch that´s ended if I move the finger, if I touch and let go at the same spot it does not reckonize it, If I am wrong please correct me

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

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

回答1:


it has never worked even to me, you should implement this method which is very simple to use

-(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 {

}

and add into your init this:

[self setTouchEnabled:YES];


来源:https://stackoverflow.com/questions/16519219/kobold2d-kkinput-anytouchendedthisframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!