Hi,
I will try to be concise, this is what I needed to achieve.
I have 5 individual images(pickups) that will spawn over several levels.
When a pickup is collected it is displayed at the bottom of the screen.
Once all five images(pickups) are collected an extra life is added.
Now I create the pickups in a loop calling five images.
I then add a collision listener to the images.
I can reference the pickups x,y positions using
pickup[1].x = xPos
pickup[1].y = yPos etc
but I cannot reference them in the collision listener, the listener is acting on all of them as a whole.
Also, the pickups are added to layer.content
but in order for the pickups to stay visible after collision I need to add them to layer.guis so they stay on screen as the game progresses. Is that possible to change the objects layer in realtime? I tried but didnt have any success.
some code:
[lua]
local function spawnExtra ()
letters = {}
    for i=1, 2 do
      letters[i] = display.newImageRect(layer,“images/letters/”…i…".png",54,54)
      physics.addBody( letters[i],“static”,{filter = filtersModule.gem, radius=24} )
      letters[i]:addEventListener(“collision”,letters)
end
    letters[1].x = math.random(30,300)
    letters[1].y = math.random(150,1000)
    letters[2].x = math.random(30,300)
    letters[2].y = math.random(150,1000)
    letters[3].x = math.random(30,300)
    letters[3].y = math.random(150,1000)
    letters[4].x = math.random(30,300)
    letters[4].y = math.random(150,1000)
    letters[5].x = math.random(30,300)
    letters[5].y = math.random(150,1000)
    function letters:collision(event)
        if letters[1] then
          display.remove(letters[1])
      letters[1] = nil
      letterEpos()
        end
        if letters[2] then
          display.remove(letters[2])
          letters[2] = nil
          end
end
function letterEpos()
      letterE = display.newImageRect(layer, “images/letters/1.png”,54,54)
      letterE.x = 100
      letterE.y = 300
    end
  end
  spawnExtra()
