PrimaryFeather / Sparrow-Framework

The Open Source Game Engine for iOS
http://www.sparrow-framework.org
Other
538 stars 173 forks source link

SPDisplayObjectContainer.sortChildren #1057

Closed tconkling closed 12 years ago

tconkling commented 12 years ago

a method for sorting a DisplayObjectContainer's children (just trivially calls through to NSMutableArray.sortWithOptions:)

PrimaryFeather commented 12 years ago

Thanks, that's great! I added that method to Starling recently, so I had to port it to Sparrow, anyway. I'll move the sample to the class documentation on the top, but other than that, the code looks perfect! =)

PrimaryFeather commented 12 years ago

Thanks again! I just added this to the core.

I had to remove the sortOptions though, to stay compatible with iOS 3; and I added a basic unit test for the functionality.

tconkling commented 12 years ago

Ah, I didn't look at the compatibility for that function. Though it looks like -sortUsingComparator: is also not compatible with iOS 3...

(Using a stable-sort method is pretty important when sorting display objects. Non-stable sort methods result in objects of equal depth flickering as they swap positions in the display list.)

PrimaryFeather commented 12 years ago

Ah, you're right ... I could have sworn I read "iOS 3" in the documentation -- my fault.

Hm ... well, it might work anyway; it doesn't need to compile with the 3.0 SDK, it only has to run on iOS 3.0 -- I'm using several block functions elsewhere already which are not available in the 3.0 SDK.

-- I'll test it, and will then use the stable-sort method, of course!

PrimaryFeather commented 12 years ago

OK, it doesn't work in iOS 3. Bummer. But the heck with it -- people don't have to use it, do they? I just documented that it's only available in iOS 4, and throw a nice exception if someone calls it. ;-)