I've just updated my project to Cocos2d v2.0 and after getting rid of all build errors, i can get it to run but the game seems to draw things in the wrong place. Buttons/menus are clickable where they're supposed to be, but the sprites show up in the wrong place, or not at all. (This project was my copying old files into a new v2.0 project from a template.)
I'm also getting openGL errors like this
OpenGL error 0x0502 in -[CCGLView swapBuffers] 280
OpenGL error 0x0502 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCSprite draw] 532
OpenGL error 0x0502 in -[CCTextureAtlas drawNumberOfQuads:fromIndex:] 556
So, I reread the migration post... removed the RootViewController stuff, etc, then created a new project from the v2.0 template and made my appDelegate look just like it. I double checked my CCSprite -draw method, looks just like it's supposed to in v2.0
No change. Still OpenGL errors and most of my sprites are out of place. (background seem fine, oddly enough.)
This is happening when using the 5.1 or 6.0b4 IOS Simulator
I'm at a loss.. :(
Anyone have any ideas? I've exhausted my search options and am just frustrated .. thanks ahead of time!
(FYI, this was a fully working v1.0.1 game)
UPDATE:
SUCCESS!!! So, I had a third part class (SWScrollView .h and CCNode+Autolayout.h) that was using
glPushMatrix() and glPopMatrix()
updating those to
kmGLPushMatrix() and kmGLPopMatrix() fixed all of the errors and sprite placement!!!
Cocos2D 2.0 uses OpenGLES2.0 but cocos2D 1.0 uses OpenGLES1.0.
Here is one similar thread, follow my answer. Replace ur draw function.
Related
like the post says, I am using SpriteBuilder 1.1.0-rc and I am having a problem with joints. The issue is that I drag the joints into the scene and then I link to the bodies, but when I build the project in Xcode, the joints are not working. I used to do joints by code in SpriteBuilder 1.0, and also in this version, but I want to know how I can do this only with SpriteBuilder, what am I missing?
Some screenshots over here
I have just started with Cocos2d 3.0 after using 1.1 for a long time.
I wanted to test the shaders out and looked up some tutorials.
All tutorials seems to use the CCSprite property "shaderProgram".
When I try it like this:
renderTexture.sprite.shaderProgram = [[CCGLProgram alloc] initWithVertexShaderByteArray:ccPositionTextureA8Color_vert fragmentShaderByteArray:ccPositionTextureColorAlphaTest_frag]
Xcode gives me an error saying: "Property 'shaderProgram' not found on object type CCSprite *"
Is this property removed or changed from version 2.0 to 3.0 and how would I go about using it in Cocos2d 3.0?
Thanks!
Adding this import:
#import "CCNode_Private.h"
allows you to access CCNode's shaderProgram memberc
My app is using both UIkit and cocos2d. After using view with GoogleMap SDK and show cocos scene. xcode show this:
cocos2d: surface size: 0x0
Failed to make complete framebuffer object 0x8CDD
And the screen is black, and can do nothing except restart app.
I have searched so many website, so many people have same problem but no solution for that.
So is it impossible to use Google Map sdk with cocos2d? If not what can I do?
(Before using GoogleMapsdk I used MKMapview, it doesn't cause this problem but it's not as good as GoogleMap)
Google Maps uses OpenGL ES to render the map. Two OpenGL renderers can not be mixed, they both use their own GL context. Specifically on iOS there seems to be little support to run two GL views side by side (let alone on top of each other).
So no, for all intents and purposes mixing cocos2d and google maps on iOS is not possible.
I've made a game that uses cocos2d to display graphics, and uses a lot of MPMoviePlayerController to display cutscenes.
The problem is - the game stopped working on iOS 4.3. It was fine up until iOS 4.2, but on iOS 4.3 the movies play OK, the gameplay also happens, but the screen is all black when not playing the movies.
I have a hard time tracking the problem. Suggestions?
Edit: I narrowed the thing down to MPMoviePlayerController - if I disable it, everything is fine. I guess something changed in 4.3?
MPMoviePlayerController's view is clear in 4.0-4.2, and black in 4.3 by default, what helped was:
MPMoviePlayerController* moviePlayer = ...
moviePlayer.view.backgroundColor = [UIColor clearColor];
MPMoviePlayerController* moviePlayer = ...
[moviePlayer.backgroundView setBackgroundColor:[UIColor whiteColor]];
// or set need color
read more in "MPMoviePlayerController Class Reference"
I read a topic on OpenGL.org where a guy made this:
http://coreytabaka.com/programming/cube-demo/
He said to release the source code but he never did,
does anyone how I could get the same idea?
Has to do with clearing the window with alpha but drawing
on it as well.. just don't get how to get OpenGL setup like
that. From there I can do my stuff but I'd like a base for
this running in C++ with VisualStudio,
Anybody has something like this laying around ? Or can show
pieces of the code to get this kind of rendering done.
Render the 3d scene to a pbuffer.
Use a color key to blend the pbuffer to screen.