I want to load an image behind another image, instead of in front of it. I thought the code in the Follow Me sample code might work, but I haven’t had any luck so far. Any help would be appreciated. [import]uid: 4871 topic_id: 612 reply_id: 300612[/import]
I’m not behind my computer right now but I remember there being a variant of inserting into a group with an extra parameter, namely the index in the stacking order. Something like
group.insert(obj, index)
you might be able to insert something behind something else that way.
Arjan [import]uid: 4824 topic_id: 612 reply_id: 1189[/import]
Thank you. I will try this and post it back on the forum if I get it to work. [import]uid: 4871 topic_id: 612 reply_id: 1193[/import]
Yes, group.insert(obj, index) is the preferred way.
C [import]uid: 24 topic_id: 612 reply_id: 1197[/import]
I am going to keep working at it, but right now the way I am entering that line of code is crashing the simulator.
local Enemy1AttackImage = display.newImage( “Enemy1Attack.png”, 50, 50 )
local ATKGroup = display.newGroup()
ATKGroup.insert(Enemy1AttackImage, 1) — <===== I assume this is how that works
[import]uid: 4871 topic_id: 612 reply_id: 1205[/import]
From the documentation:
group:insert( [index,] child, [, resetTransform] )
So there is a *colon* (
instead of a dot (.) between group and insert and the index comes *before* the object to insert. In your case it would be:
ATKGroup:insert(1, Enemy1AttackImage)
Does that help?
Arjan [import]uid: 4824 topic_id: 612 reply_id: 1206[/import]
I just saw a period that should have been a colon… After that I just had to figure out how to get it in the right spot because the group was causing the transition to act very strangely. The code “transition.from” fixed the problem and now it works great.
Much thanks to both of you for helping. [import]uid: 4871 topic_id: 612 reply_id: 1208[/import]
Yes, the : . bites! even us here. (me specially coming from C++ where the methods use :: notation).
Best
Carlos [import]uid: 24 topic_id: 612 reply_id: 1210[/import]