I can’t find a way to set the Z - order of the object in Corona. Like Cocos2D is it possible to set Z order? [import]uid: 97897 topic_id: 19908 reply_id: 319908[/import]
Objects can be moved to the front or to the back. I’ve not found any other controls:
ball:toFront()
and
ball:toBack()
[import]uid: 19626 topic_id: 19908 reply_id: 77357[/import]
I have found it easy to accomplish this by using levelhelper. LevelHelper has this feature built in so you can set the Z-order of any game object. If you do not want to purchase levelhelper, I found that the object will appear in the order you put them in, so:
[code]
–will be displayed in front
local ball = display.newCircle(100, 200, 30)
–will be displayed in front of ball
local square = display.newRect(100, 200, 200, 100)
–or something similar to this [import]uid: 38977 topic_id: 19908 reply_id: 77361[/import]
group:insert( position, object)
edit:
you can reinsert an object into a group and it will insert it into the new z order if you omit position its insert in front [import]uid: 7911 topic_id: 19908 reply_id: 77360[/import]
Someday’s I feel like a total Corona SDK n00b. I did not know I could insert at a specific position!!!
Thanks @jstrahan… that may be the most useful thing I’ve learned this year!
[import]uid: 19626 topic_id: 19908 reply_id: 77363[/import]
Thank you @jstrahan and @robmiracle for the info.
Btw @jstrahan how do I declare the position when inserting into groups? Is it declared as number (1,2,3…) or anything else? :\
Thanks in advance.
Rodrigo. [import]uid: 89165 topic_id: 19908 reply_id: 77365[/import]
yeah i think we all feel like a n00b every now and again
i know i have last few days working on some tables [import]uid: 7911 topic_id: 19908 reply_id: 77366[/import]
index
number: Inserts child at index into group, shifting up other elements as necessary. The default value index is n+1 where n is the number of children in the group.
An easy way to move an object above all its siblings (top) is to re-insert it: object.parent:insert( object ).
If a group has 3 display objects:
group[1] is at the bottom of the group.
group[2] is in the middle of the group.
group[3] is at the top of the group.
Objects at the higher index numbers will be displayed on top of objects with lower index numbers (if the objects overlap).
http://developer.anscamobile.com/reference/index/groupinsert [import]uid: 7911 topic_id: 19908 reply_id: 77367[/import]
@jstrahan - Thanks for the reply and sorry for not finding it inside the Docs. :\
Rodrigo. [import]uid: 89165 topic_id: 19908 reply_id: 77369[/import]
@RSCdev thats alright we all miss something sometimes
[import]uid: 7911 topic_id: 19908 reply_id: 77376[/import]
If an object is already in the group, and you are inserting at a higher index, it will remove the object and shift the indices before inserting (I believe)
E.g.
Say your group has the following:
obj1 = group[1]
obj2 = group[2]
obj3 = group[3]
obj4 = group[4]
obj1 is the object of interest
group:insert(3, obj1) --> you are now inserting into a group with this order:
obj2 (now group[1])
obj3 (now group[2])
obj4 (now group[3])
So the final result is:
obj2 (now group[1])
obj3 (now group[2])
obj1 (now group[3])
obj4 (now group[4]) [import]uid: 62193 topic_id: 19908 reply_id: 77402[/import]
@dmoore764 - Nice example!
Cheers,
Rodrigo. [import]uid: 89165 topic_id: 19908 reply_id: 77425[/import]
Epic win on that info!!!
Holy crap, I am with @robmiracle on that may be the best thing I’ve learned this year too! …wait, was that a play on the year being a few days old!!!
Thanks everyone for the info and discussion!
-Mario [import]uid: 11636 topic_id: 19908 reply_id: 78865[/import]
Yes, it was a play on the year only being a few days old, but none the less, it’s a very important thing to have learned. [import]uid: 19626 topic_id: 19908 reply_id: 78912[/import]
awesome, i didnt even know this feature for groups, what headache they gave me ) [import]uid: 16142 topic_id: 19908 reply_id: 78918[/import]