Using depth buffer on a sprite

I am following this guide:

http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:tiled_maps

Trying to create a tiled map that also supports multiple layers. The guide says that a way is to use depth buffer, and says to:

1) Create the z-buffer and a 2D projection; 2) For every layer in the tiled map, set the cc_vertexz attribute; 3) Enable alpha test and set the sprite alpha func.

The first question is: if I use a tiled maps with multiple layers, are also the point 1 and 3 needed?

I am fine with the first two points, but as for the third point I don't know how to do that. I should subclass CCSprite and override the draw method, but the problem is that when I create a tiled map there are already sprites on it, so the instances don't belong to the subclass I created. How I go around this?

There are 2 methods described in the guide, Using multiple TMX Layers and z-order and Using Depth Buffer. It would be better to use Using multiple TMX Layers and z-order as it is easier to use and it uses cocos2d's drawing and z-order structure.
1) is not needed as every tile in CCTMXTiledMap is a CCSprite, where the order of rendering depends on the z-order of CCSprite. Using multiple TMX Layers and z-order has described how it works.
If you insist on using Using Depth Buffer, 1) 2) and 3) are required. You can override CCTMXLayer/CCSpriteBatchNode's draw to enable the alpha test before [textureAtlas_ drawQuads];, instead of every CCSprite. The order of CCSprite is not important because z-buffer is enabled.