Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]

Inserting to a specific group index
Started by Guest Feb 03 2010 11:31 AM

- - - - -
2 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Guest__*

[GLOBAL: userInfoPane.html]
Guest__*
  • Guests

From the API guide: group:insert( [index,] child, [, resetTransform] )

I want to insert an item at the back of the group, or group[1]. If i have a group and I add an item, say it has 4 items in it, the 5th item will be group[5]. I could probably do a for loop to re order things for me but it seems like I should be able to insert something into a group at any index I want, but it doesn't seem to work, and the for loop could end up being costly cpu wise. Probably not for what I'm doing, but if it were a bigger project.

Ideally, I would want it to work like this (assume I've already got 4 items in my group):

[code=auto:0]
local img = display.newImage("foo.png",0,0)
group:insert(img[1]) -- where I insert "img" into whatever index I want, bumping everything else up

Even the manual says:
Inserts child at index into group, shifting up other elements as necessary

Unless I'm reading it wrong...

Am I right in thinking that the group method was added to Lua by Ansca?
uid: 0 topic_id: 443 reply_id: 300443


[TOPIC: post.html]
#2

jondanao

[GLOBAL: userInfoPane.html]
jondanao
  • Observer

  • 21 posts
  • Guests

Korben,
group:insert(1, img) -- inserts displayObject at the bottom of the stack
group:insert(img) -- insert displayObject at the top of the stack
Jon
uid: 3544 topic_id: 443 reply_id: 856


[TOPIC: post.html]
#3

Guest__*

[GLOBAL: userInfoPane.html]
Guest__*
  • Guests

I swear I tried that...

thanks
uid: 0 topic_id: 443 reply_id: 858



[topic_controls]
[/topic_controls]