Search code examples
objective-ccocos2d-iphonekobold2d

Inserting CCParticleSystemQuad between sprites in different CCSpriteBatchNode's


I currently have a few layers in a Cocos2d scene (running in Kobold2d). Each layer has a sprite batch node attached to it. I need to use batch nodes given the ridiculous number of sprites I have on screen at once. Everything is working fine, and I've set up a little particle system. Problem I'm running into is CCParticleBatchNode particle emmiters are always on top of everything (as it is the highest zOrder's layer) - but this is an isometric game and obviously doesn't work.

Is there a way that I could sneak the emmiters between the sprites on any of my layers containing CCSpriteBatchNode's? I've tried messing around with vertexZ (I'm on the newest version of cocos2d 2.+) but it doesn't matter what I do, it doesn't seem to change anything, even though the LUA file for Kobold2d that would enable this is set properly and the shader for programForKey:kCCShader_PositionTextureColorAlphaTest on my batch nodes is enabled - but maybe this isn't even the best solution?

Has anyone run into anything like this or suggest any sacrifices I could make or tricks I could do that I'm not thinking of?


Solution

  • To use vertexZ you need to enable depth buffering (see config.lua). Vertexz is the only way to change draw order between spritebatches and other nodes.