我正试图在一些UIKit视图之上创建一个cocos2d场景。 据我所知,cocos2d 2.0 CCDirector是UIViewController的子类,因此我可以将其添加为子视图。
我已经编写了这个函数来处理切换到appDelegate中的场景(目前这是我的MainWindow.xib的委托,后面是http://www.raywenderlich.com/4817/how-to-integrate-cocos2d-and-uikit ) :
- (void)switchToScene { self.viewController = [CCDirector sharedDirector]; [[CCDirector sharedDirector] view].center = self.window.center; [self.window addSubview:[self.viewController view]]; [[CCDirector sharedDirector] runWithScene:[CCTransitionSlideInL transitionWithDuration:1 scene:[BattleLayer scene]]]; }所以我从这段代码中遗漏了很多。 但有了这个,我得到一些场景的相似性来加载http://i.stack.imgur.com/pubWE.png
我的问题是:
1:如果我朝着正确的方向前进
2:如果是,下一步是手动调整场景的方向吗?
2.1:我该怎么做:)
I'm trying to make a cocos2d scene on top of some UIKit views. I understand that the cocos2d 2.0 CCDirector is a subclass of UIViewController so that I can just add that as a subview.
I've written this function to handle switching to a scene in my appDelegate (currently thats the delegate of my MainWindow.xib following http://www.raywenderlich.com/4817/how-to-integrate-cocos2d-and-uikit):
- (void)switchToScene { self.viewController = [CCDirector sharedDirector]; [[CCDirector sharedDirector] view].center = self.window.center; [self.window addSubview:[self.viewController view]]; [[CCDirector sharedDirector] runWithScene:[CCTransitionSlideInL transitionWithDuration:1 scene:[BattleLayer scene]]]; }So I'm missing quite a bit from this code. But with this, I get some resemblance of a scene to load http://i.stack.imgur.com/pubWE.png
My question is:
1: If I'm going in the right direction
2: If it is, is the next step to manually adjust the orientation of the scene?
2.1: How do I do this :)
最满意答案
我不确定你希望它看起来如何,但似乎CCDirector的视图旋转90度CW。 这可能是由于以下几个原因:
你添加错误的视图(即旋转90度CW) 旋转设备并且CCDirector没有旋转(在这种情况下,你应该查看方向参数以及旋转的人和内容。可能是应用程序旋转但是CCDirector没有收到旋转标记)。 你可以用CGAffineTransformRotate旋转CCDirector视图(我不确定..但因为CCDirector是UIViewController的子类...它应该工作)。I solved the issue by creating a UINavigationController
- (void)switchToScene:(CCScene *)sceneObj { navController_ = [[UINavigationController alloc] initWithRootViewController:director_]; [window_ setRootViewController:navController_]; [[CCDirector sharedDirector] pushScene:sceneObj]; }更多推荐
发布评论