我正在使用cocos2D开发游戏,我正在从我的家庭视图(一个viewController类)转移到gameScene。我在主屏幕中使用UIButton,我使用CATransition
动画在视图出现时显示按钮。加载游戏场景时,我没有释放主视图。主视图出现在游戏场景的后面。当游戏场景结束时,我隐藏游戏场景并显示家庭场景。
这是创建按钮的代码:
// Play Button
btnPlay = [[UIButton alloc]init];
btnPlay.frame = CGRectMake(65,95,124,50);
[btnPlay addTarget:self action:@selector(btnPlayAction) forControlEvents:UIControlEventTouchUpInside];
[btnPlay setBackgroundColor:[UIColor clearColor]];
[btnPlay setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[btnPlay setHidden:YES];
btnPlay.titleLabel.font = [UIFont fontWithName:@"NoteWorthy" size:25.0f];
[btnPlay setBackgroundImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];
[self.view addSubview:btnPlay];
[btnPlay setShowsTouchWhenHighlighted:YES];
这是按钮CATransition
的代码:
CATransition *animation3 = [CATransition animation];
[animation3 setDuration:3.0f];
[animation3 setType:kCATransitionReveal];
[animation3 setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[btnPlay layer] addAnimation:animation3 forKey:@"SwitchToView"];
[btnPlay setHidden:NO];
对于少数重播,过渡进展顺利。但是经过几次游戏重播后,有时kCATransitionReveal
会发生,有时会发生kCATransitionFromLeft。但我没有在我的代码中使用kCATransitionFromLeft
。它是如何发生的?
感谢您的帮助。