Used the Ray Wenderlich tutorial "How to Intergrate UIKit and Cocos2D" mentioned here and it worked great unthil iOs6 was released, then, I get the "Orientation Problem on iOS 6"...
Help? How to apply the fix for the rotation problem? http://www.cocos2d-x.org/news/73
Note: My question is for a project that combines UiKit and Cocos2D like Ray's tutorial?
I have posted my code excerpt and structure here:
http://www.raywenderlich.com/forums/viewtopic.php?f=20&t=1081&p=34166#p34166
I am sorry that I am a beginner :(
Where should I apply the two parts of the fix?
In MainMenuViewController.m?
Or, do I need to download the lastest Cocos2D framework and redo a lot of development for theis almost completed app..?
Cheers,
Andrea
The way I solved it is by following the solution in the comments to this implementation (which is similar to the one in the RW tutorial):
Tinytimegames - cocos2d and storyboards
The specific code posted by "Pierre" there is:
And if you want your glView to resize:
CCGLView *glView = ...
glView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
This forces the glView to resize automatically when the device orientation changes.
Related
Hello I'm very new to OpenGlES and i have started to try to learn it with online tutorials... but in each tutorial they ask me to create a OpenGL ES Xcode project, and then edit EAGLView.h. But I can't find it. Is it just me or has Xcode 4 changed its location etc. Also, when I run the application it gives me two cubes... 1 red and 1 blue... spinning around. In some tutorials, there is simply a multicoloured box, not in 3 dimensions. Is it possible to go back to that?
Thanks
The sample application has changed significantly since the tutorials you are reading was written.
EAGLView, in its many incarnations, provided a UIView subclass that connected OpenGL to UIKit. As of iOS 5 there's no need for a custom class because of the introduction of GLKit. The modern OpenGL sample simply uses a GLKView, which is a built-in UIView subclass connecting OpenGL to UIKit.
What the sample actually shows has also changed to highlight the vector manipulation parts of GLKit that provide everything GL ES 1.1 supplied but which was cut from ES 2.0, and more.
If you want to work up from a tutorial, you're probably going to have to find a newer one. Searching for GLKit tutorials directly is probably the best idea — this one (amongst many others) looked like it covers mostly the modern stuff, for the sake of saying something rather than nothing.
Instead of EAGLView.h and m, they have moved all of the code into files named viewController.h and m.
If you have truly generated an "OpenGL Game" project as they are calling it in the newer versions of XCode!
In terms of the OpenGL code implemented to show the red and blue boxes etc... They have changed there sample code, you can from the m file put whatever you want there!!!
You can download sample code from here and work from that:
http://developer.apple.com/library/ios/#samplecode/GLES2Sample/Introduction/Intro.html
I'm having some troubles integrating a cocos2d scene inside a tab of an existing app.
I developed the scene using the Xcode template that comes with cocos2d and it works fine, but when I try to load the same scene on the existing app all that comes out is a black screen.
Here's the code I run when I load the UIViewController linked to the tab
-(void)viewDidLoad {
director = [CCDirector sharedDirector]; //declared in the header file
//declared in the header file, sized as whole screen minus the tab bar
coolview = [CCGLView viewWithFrame:CGRectMake(0,0, 320,321) pixelFormat:kEAGLColorFormatRGB56 depthFormat:0 preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0];
[director setView:coolview];
[self setView:coolview];
[director setAnimationInterval:1.0/60];
[director setDelegate:self];
[director setProjection:kCCDirectorProjection2D];
[director runWithScene:[HelloWorldLayer scene]];
}
Any idea why I should get a black screen? What am I missing?
The code in the HelloWorld layer is executed, the objects are instantiated but it just seems like they don't get rendered.
I get the following feedback also:
OpenGL error 0x0501 in -[CCShaderCache loadDefaultShaders] 174
OpenGL error 0x0501 in -[CCTextureAtlas initVAO] 167
OpenGL error 0x0501 in -[CCDirector setView:] 308
OpenGL error 0x0501 in -[CCTextureAtlas initVAO] 167
but I haven't been able to find the meaning of the error codes.
I'm using cocos2d version 2.
Thanks in advance for any help
Luca
A little update: this problem does not happen with version 1.0.1, replacing CCGLView with EAGLView.
So I'll assume this might be a little bug of this release.
Unfortunately I can't switch to 1.0.1 because I need some features of box2d v2.2 that comes only with cocos2d v2.0.
I'm trying to make box2d v2.2 work with cocos v1.0.1 but it's getting pretty ugly!
Anyone knows how I could fix it in 2.0 or at least point me in the right direction? Where could the problem be? In CCDirector or CCGLView?
Thanks
Luca
You have to have all the Cocos2D initialisation code as well. Cocos2D creates an openGL rendering context which is then drawn to to display the sprites. If you look at the template app that comes with cocos, in the AppDelegate, there is a load of initialisation stuff.
I'm not even sure if it is possible (or if it is, if it is easy) to incorporate a cocos2d scene into an existing iOS app.
After you'll done with all initialization stuff, Nick Bull talking about, you'll need to note one thing: cocos2d draws on his own CCLayer. But I think this layer, and the layer, wich is in all UIView sublasses - is the same things. If you'll fine the way to replase them, or link somehow, you'll can do any cocos2d staff in your views. This should be starting point for you, good luck.
I want to have Mobfox in my AdWhirl rotation but I can't seem to find any documentation on how to do this, I know that Mobfox is unsupported with AdWhirl. Any one got any experience with this? I'm an iPhone developer.
there is a way to do this! check out this post:
Combining MobFox/AdWhirl on iOS
hope this helps
Im trying to add a slider for the settings page in my game, i have looked around but there doesnt seem to be much info.
Anyone help at all?
Cheers
Maybe this thread on the Cocos2d forum will help you. It tackles the problem you describe. As a conclusion it says that:
It can only be done using MPVolumeView
Read this piece in the Apple Developer documentation for more about the MPVolumeView.
Anyone know whether (and if so, how) we can create the half-turned page effect Google Maps on the iPad uses to show the options to change the Map type?..
See below image to see what I'm talkin' about..
Incidentally, any pretty good Map Kit tutorials you guys know of that are out there? (covering anything new brought on through iOS4) Support for Map Kit ain't much out there it seems...
Thanks!
It's a new UIModalTransitionStyle in iOS 4.0 called UIModalTransitionStylePartialCurl
re: good mapkit tutorials, watch the WWDC map overlays video.