Front Most Object or Top Most Object

Hello there,

I am creating a game similar to sticks for iphone and I am stuck at finding the top most object.

I have spawned random sticks in random rotation, but I dont know on how to recognize the top most stick(object).

is there any code like

if Object is in Front == true then?

Thanks in Advance.

Edit: it’s like Pickn’ Stix iphone Game [import]uid: 72500 topic_id: 12110 reply_id: 312110[/import]

Hmmmm…is the most recent object drawn always the top most? If so, maybe you can assign a counter to each object as it is created and then compare these to see which value is higher. The higher value between two objects belongs to the top most. [import]uid: 58455 topic_id: 12110 reply_id: 44125[/import]

Assuming that all of your sticks are being placed inside a single display group that contains only sticks, then you can access the topmost object using:

[lua]local topObject = myGroup[myGroup.numChildren][/lua]

Basically, a display group can be treated as a table/indexed array, where the child display objects can be accessed using an integer index. If the display group contains other non-stick objects, then you’d have to test to make sure the topObject is in fact a stick, and if not then test the next topmost object, (numChildren - 1), repeating this until you get a stick. Much more efficient to just group the sticks altogether, if possible.

Thanks,
Darren [import]uid: 1294 topic_id: 12110 reply_id: 44131[/import]