Is there a way in gideros to sort a sprites children/class instances by one of the fields?
eg
-- a load of baddie children, all having different y's
scene.baddies:sort(y,true) -- the 1st param says what field to sort by, the 2nd true or false for accending or decending sort
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
https://deluxepixel.com
Comments
https://deluxepixel.com
http://developer.coronalabs.com/forum/2010/11/08/z-order-graphic-objects
Basically I want to be able to reorder the objects based upon a z-order.
https://deluxepixel.com
scene:addChildAt(scene.baddies[2],5)
scene:addChildAt(scene.baddies[5],2)
You would just need to make you swap the lower to greater index first, so you didn't throw off later swaps.
A common c lib to do this (possibly popular function) would be better though...
Likes: MobAmuse
https://deluxepixel.com
Likes: SinisterSoft
https://deluxepixel.com
Likes: SinisterSoft
But how do I sort (using the lua sort) something like:
objects={}
.
.
.
noObjects=noObjects+1
objects[noObjects]={}
objects[noObjects].depth=255
objects[noObjects].type=0
based upon the depth part of the table?
https://deluxepixel.com
Likes: SinisterSoft
https://deluxepixel.com
I create a table of currently visible objects (on screen) with a depth field. Some matter, (real properly 3D tracked things like baddies) some don't (asteroids, plasma weapons, smoke trails). I sort them so that baddies will move in front of or behind objects visibly (when they do properly code wise).
Lua and garbage collection are the bottle necks for me to keep the speed up. That's why I was so concerned about adding and removing things. I like to do that as little as possible.
I'm only spending an hour or two every couple of days or so on the game as I have a Windows program I wrote that I need to support/market during the day. It's coming along though.
I'll post another video soon...
Likes: gorkem
https://deluxepixel.com
https://deluxepixel.com