Object won't pass through

I am confused as to why I can’t get my shape object to pass through to the “Wrap” function. What am I missing when the shapes are “spawned.” Is there a better way to “create the shapes” on screen within the tables? All of this is functioning except I am having trouble pushing the shapes through the functions that require “enterFrame” listeners.

[code]
local function postSpawnAction(obj)
physics.addBody(obj, “dynamic”, {density = 0, friction = 0, bounce = 1, radius = 20})
obj:applyForce( math.random(1,3), math.random(1,3), obj.x, obj.y )
end
–WRAP SHAPES WHEN EXITING SIDES
local function wrap(obj)

if obj.x < 0 then
obj.x = _W
end

if obj.x > _W then
obj.x = 0
end
end
if(gameReady == 1 )then
Runtime:addEventListener(“enterFrame”, wrap)
end

–APPLY CHOSEN SHAPES TO SHAPES ON SCREEN TABLE
local function spawnRoundShapes()
for i=1, numThisRound do
n = shapesChosen[i]
table.insert(shapesOnScreen, i, allShapes[n])
end

–check spawn accuracy
for i=1,#shapesOnScreen do print(“shape Number " … shapesOnScreen[i].num … " spawned”) end

–Spawn the shapes
for i=1,#shapesOnScreen do
shapesOnScreen[i].name = display.newImageRect(shapesOnScreen[i].img, 50,50)
shapesOnScreen[i].name.x = _W/2; shapesOnScreen[i].name.y = _H/3
shapeGroup:insert(shapesOnScreen[i].name)
postSpawnAction(shapesOnScreen[i].name)
wrap(shapesOnScreen[i].name)
end

end

[/code] [import]uid: 10361 topic_id: 8302 reply_id: 308302[/import]

Perhaps line 40 should be only!?

[lua] wrap(shapesOnScreen[i])[/lua] [import]uid: 42078 topic_id: 8302 reply_id: 29595[/import]

Thanks for the reply!
Hmm. That doesn’t work. I think because I’m using the “table.name” to create the display object and thus that becomes my object onscreen. However I don’t know why this won’t work the way it is.

EDIT: It clearly pushes them through the physics.addBody and applyForce function. [import]uid: 10361 topic_id: 8302 reply_id: 29597[/import]

Well I think I found a solution. I don’t know if there’s another way at the moment. But I’m putting all my shape action functions like “wrap” inside the for loop.

If anyone can show me a better way, I’m all ears :slight_smile:

Thanks for looking. [import]uid: 10361 topic_id: 8302 reply_id: 29646[/import]