Cocos2d、UIKit与Kobold2D开发指南
1. Cocos2d与UIKit视图交互
在开发中,有时需要使用分段控件(Segmented Control)的按钮来改变Cocos2d视图中的场景。以下是实现该功能的代码示例,该代码来自ViewController类的sceneChanged方法:
- (IBAction)sceneChanged:(id)sender
{
CCDirector* director = [CCDirector sharedDirector];
if (director.view.hidden == NO)
{
UISegmentedControl* sceneChanger = (UISegmentedControl*)sender;
int selection = sceneChanger.selectedSegmentIndex;
CCScene* newScene = [HelloWorldLayer scene];
CCScene* trans = nil;
if (selection == 0)
{
trans = [CCTransitionSlideInL transitionWithDuration:1 scene:newScene];
}
else if (selection == 1)
{
trans = [CCTransitionShrinkGrow transition
超级会员免费看
订阅专栏 解锁全文
73

被折叠的 条评论
为什么被折叠?



