Cocos2d场景加载方向错误(Cocos2d scene loaded with wrong orientation)

编程入门 行业动态 更新时间:2024-10-25 20:24:35
Cocos2d场景加载方向错误(Cocos2d scene loaded with wrong orientation)

我正试图在一些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]; }

更多推荐

本文发布于:2023-08-07 19:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465941.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:场景   加载   方向   错误   Cocos2d

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!