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]
