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

时间:2012-09-17 10:36:53

标签: iphone cocoa-touch

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

在每一层上,我添加一些静态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];
    }



}

1 个答案:

答案 0 :(得分:0)

想出来,[CCDirector sharedInstance]暂停了。