I am currently making an iPad platform game using Cocos2d and are planning on including multiplayer split-screen. I have done some initial work creating multiple layers, scaling them down and rotating them. This works fine except it is a bit of a pain having to put everything I create in the two layers. i.e. If I want a sprite in the ‘world’, I then need to add it to both players layers, the same for particle effects, tilemaps etc…
Is there a better way to do this?
I would have thought that I could have one layer (my world) and then have two separate views of it using different viewports. Unfortunately OpenGL knowledge isn’t great and I’m not too sure how best to do this using Cocos2d? Has anybody done this before and got a tutorial or any sample code? I’ve searched google but haven’t been able to find anything that useful.
I’ve changed the way I’m doing it now. I’ve overridden the visit function for the layer to setup two viewports of the same layer and rendering it twice (once into each view port). Between each render ([super visit]) I adjust the position of the layer because that’s how I’m doing the camera.
// Setup the top viewport
glViewport (0, 0, clippingRegion.size.width/2, clippingRegion.size.height);