尽管 FPS 为 60,但屏幕上的内容更新速度很慢



>我正在加载一个菜单,其中有 7 层,我滑动穿过这些层。在第一次加载时,滑动以 60fps 的速度平滑,但我随后弹出场景并再次推动它,滑动非常慢,尽管应用程序显示 60fps,并且 ccTouchesMoving 的调用间隔与第一次加载时大致相同。

在每一层,我添加了一些静态的CCSprites和一个CCMenu。

所有项目都已解除分配,我正在iPad 3上测试该应用程序(因此速度不是问题)。

我认为原因更多地在于设置部分,并希望找到解决方案。以下是我的触摸方法,如果有帮助的话:

- (void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{
    UITouch *touch = [touches anyObject];
    CGPoint location = [touch locationInView: [touch view]];
    location = [[CCDirector sharedDirector] convertToGL:location];
    //Swipe Detection Part 1
    firstTouch = location;
}

-(void)ccTouchesMoved:(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];
    CGSize winSize = [[CCDirector sharedDirector] winSize];
    for(int i=0;i<[layerList count];i++)
    {
        [[layerList objectAtIndex:i] setPosition:CGPointMake((i-currentLayer)*winSize.width + (location.x - firstTouch.x),0) ];
    }
}
-(void)ccTouchesEnded:(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];
    //Swipe Detection Part 2
    lastTouch = location;
    //Swipe Detection Part 2
    lastTouch = location;
    //Minimum length of the swipe
    float swipeLength = ccpDistance(firstTouch, lastTouch);
    //Check if the swipe is a left swipe and long enough
    if (firstTouch.x > lastTouch.x && swipeLength > 60) {
        [self doStuffLeft];
    }
    else if (firstTouch.x < lastTouch.x && abs(swipeLength) > 60) {
        [self doStuffRight];
    }

}

想通了,[CCDirector sharedInstance] 被暂停了。

最新更新