I was digging for this and even though the domain name is unforgettable apparently it’s hard to find on Google.
Today I solved a problem that I was having with z order properties for sprites in cocos2d.
Coming from a background developing applications for iphelp.com.au, it’s fairly common practice that all display objects are assigned a “Depth” that automatically iterates as children are added to the display list. So the first element becomes assigned a depth of 0, the second is assigned 1, and the third assigned 2.
So armed with that back history, I looked at the zOrder property of CCSprite.
Ok, I thought, to move something to the first z order within a layer I can just set the zOrder to zero:
[myLayer reorderChild:mySprite z:0];
No dice. I googled, and all of the samples just said “reorderChild to z of 0″. So either nobody has really done this, or I am missing the boat.
It appears that unless you add the z: parameter when adding a child to a parent, the z defaults to 0. Moving another object to 0, where it already was, does nothing.
The easiest option to get something behind other elements, is to assign a negative z value below the 0 default:
[myLayer reorderChild:mySprite z:-1];
To move something in front of all other elements, assign a positive z value above the 0 default:
[myLayer reorderChild:mySprite z:1];
I hope this helps.
Well, I’ve moved over to the dark side. Not for my full time studio work, but for our side projects.
Beginning next month IQ is going to start releasing titles on the iOS platform, beginning with a freshly ported version of Germz.
It was a tough decision to make, but the iOS platform represents the caliber of style and polish that we strive to put into our work.
After a month working within Objective-C, I’ve been able to replicate 80% of what we are able to do with Flash, and build a game that runs much much faster than a direct Adobe Air port of our desktop version with the Adobe iPhone packaging platform.
To be fair, much of this is likely due to optimizing code, programming smarter, and reducing sound playback overhead. For Germz alone, it probably wasn’t necessary to build it in Objective-C, but much like when we set out to build Germz initially it is a great exercise in building a game within a defined genre and figuring out how far we can push details and polish on a new platform.
The other games we’ve been working on went from running at 30+ fps in Air on the desktop to 5 fps on the iPhone. Again, much of this was due to our taking advantage of the advanced graphic rendering filters and animation tweens in Flash. Changing our workflow to not use those features wasn’t difficult, but it meant building things in Photoshop and writing .png sequences, which aren’t rendered as fast as animations in Flash.
We had to make a choice, and ultimately I think there is more money to be made for small independent developers who bring a high level of polish and new ideas to the App Store.
Hopefully we can do that. Wish us luck!