开发者

iphone-cocos2d: 0.9 & 0.8.2 slower than 0.7.1?

I have a code that set's a bow's angle according to where you have touched the screen. a simple "bow.rotation = X" command is performed on the ccTouchesMoved event. the problem is, that while running the code on 0.7.1 of cocos2d against 0.9 or 0.8.2 it worked way better, in 0.9 and 0.8.2 it seems like it skippes some of the touchesmove event... what could it be? heres the code...:

-(BOOL)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView: [touch view]];
    location = [[CCDirector sharedDirector] convertToGL: location];
    if(player.state == StateNotPrepared) {
        if(CGRectContainsPoint(spriteT开发者_开发百科oRect(fireButton), location)) {
            [player prepareShot];
            [powerMeter resetBar];
            [powerMeter startLoadingBar];
        } else {
            float newAngle = [player angleByTouchPoint: location];
            [self setAngles: newAngle];
        }   
    }
    return kEventHandled;
}

-(BOOL)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView: [touch view]];
    location = [[CCDirector sharedDirector] convertToGL: location];
    if(player.state == StateNotPrepared || player.state == StatePrepared) {
        if( !CGRectContainsPoint(spriteToRect(fireButton), location) ) {
            float newAngle = [player angleByTouchPoint: location];
            [self setAngles: newAngle];
        }   
    }
    return kEventHandled;
}


This may be related to the type of director used vs. the OS of the device. Try the different directors and see if you get different behavior.

[Director setDirectorType:XXXX];

Where XXXX is one of:

  • CCDirectorTypeNSTimer (default)
  • CCDirectorTypeMainLoop
  • CCDirectorTypeThreadMainLoop
  • CCDirectorTypeDisplayLink

I know that some people have reported issues with the DisplayLink director (though that's generally ideal otherwise when available).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜