I found a fix to support iPad retina display for my cocos2d game. It was unable to display anything when I ran the game in portrait mode in the ipad retina simulator. But when I changed the default setting from kCCDirectorProjection3D to kCCDirectorProjection2D it started working fine.
I want to know what exactly does kCCDirectorProjection2D/kCCDirectorProjection3D do? Will changing the default setting cause any problems?
Thanks Abhinav
3D Projection (default):
zOrder
property. zOrder
is the same as z in addChild:z:
.Looking at the picture you'll have to imagine that your nodes are all drawn at the same depths, for example directly on the back plane. Therefore they all appear at the same size. Correct overlapping of nodes is achieved merely by rendering each node in a certain order.
You can still change the true OpenGL rendering depth of nodes via vertexZ
but it is not recommended in 3D projection because it will have the effect of nodes being rendered slightly offset from their position due to the 3D projection.
2D Projection:
vertexZ
property which takes precedence over zOrder
.vertexZ
also affects the size of nodes. If you do change vertexZ
you will have to enable depth buffering in EAGLView for correct rendering. This is most often used to render overlapping tiles in isometric tilemaps correctly.With 2D projection you can now move sprites at any depth using vertexZ
without the node position being offset. However, unless you enable depth buffering, your nodes will appear smaller or larger depending on their vertexZ
property.
If you don't change the vertexZ
property of any node, 2D Projection should give identical results to 3D Projection. However some nodes or actions may require 3D Projection to work correctly.
Check the link at the end of this sentence if you want to know all the gnarly details about OpenGL projection matrices.
Both projections have the same performance characteristics. However enabling 2D Projection without using vertexZ
usually only makes sense when you're working with tilemaps.
Long story short: as long as your app works fine in 2D Projection and shows no bugs after thorough testing, you should be fine.
But I'm sure this is not the correct fix for iPad Retina. For all we know until March 16th, it could be an issue that only occurs in the iPad Retina Simulator. And the issue is more likely going to be fixed by updating the retina mode function of CCDirector.