In this post Mohammad Azam will define the purpose of making invisible walls using layers in Cocos2d framework.
There are times when you have the perfect background for your game and you want to add walls in the game without compromising the integrity of the scene. In such scenarios you can make invisible walls using layers. Invisible walls are normal transparent images drawn on top of the original drawings. Take a look at the scene below:
The screenshot above shows that eggs are bounded by the fence and are collected between the two fences. In this case the original background art was not disturbed but an invisible fence was introduced. The invisible fence was put on top of the original fence and then put in a layer below the original layer using the lower z-index value. The invisible fence should not necessarily be the transparent image but it can be a normal image pushed into the layer behind the original drawing.
This approach saves the integrity of the background art and allow us to make small yet important changes to the design of the game.