Handling Z-Ordering In Cocos2D Map Based Games

If you’ve used Cocos2D for awhile you may have had some difficult when trying to handle the display order of images.

Things get even more complicated if you are creating an isometric game.  The player character may need to be placed behind an obstacle such as a rock or a tree.  In v0.99.1 automatic z-ordering for tile maps was implemented, and the problem was somewhat solved, but some problems still exist and there is some tweaking to be done.

Another problem, especially with map-based games is creating a player HUD display as the images need to be placed at the right z-ordering and at a consistent location on the screen.

Nat Weiss has created a tutorial on how to overcome these problems by creating two different custom sprite classes which can be found here:
CCZSprite and HudLevelSprite

These two classes should be of help to anyone interested in creating a map-based game in Cocos2D.

Thanks for reading, if you like this please share it!

©2010 iPhone iOS 4 iPad SDK Development Tutorials, Programming Tips, News. All Rights Reserved.

.

Share and Enjoy:

RSS
Twitter
Facebook
DZone
HackerNews
del.icio.us
FriendFeed

Leave a Reply

Your email address will not be published. Required fields are marked *