1

我需要对此代码进行哪些更改才能使其在 Cocos2d 中工作?当方向改变时手动旋转触摸效果很好。

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
    if(UIInterfaceOrientationIsPortrait(toInterfaceOrientation)){
        [self changeTheViewToPortrait:YES andDuration:duration];
    }
    else if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation)){
        [self changeTheViewToPortrait:NO andDuration:duration];
    }
}

- (void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:duration];
    if(portrait){
        //change the view and subview frames for the portrait view
        tabBar.frame = CGRectMake(0, 420, 320, 40);
    }
    else {
        //change the view and subview  frames for the landscape view
        tabBar.frame = CGRectMake(0, 260, 480, 40);
    }
    [UIView commitAnimations];
}
4

0 回答 0