Posted by: firstpixel | September 29, 2009

Cocos2d Z-Ordering

As said on my last post here, I’ve started working on my first iPhone game and after looking around a bit decided to use cocos2d. I also decide to remake a multiplayer flash game I’ve already donne on cocos2d for Iphone.

It’s a soccer football game, a turn based one, and you have 3 coin-style players each side, for each turn both players set it’s next movement by selecting the coin and moving an arrow to the direction  you want your next move to be.

So I want the player to have the arrow last selected to be on top of other so you can see better where you might be moving to on next turn.

Here is the code for Cocos2D z ordering.

[parentNode reorderChild:spriteName z:(theZOrder)];

in my case I will do it on my ccTouchesBegan:

[self reorderChild:p1Sprite z:zOrderTop];

where zOrderTop is my last Sprite.

Hope it helps.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.