I am stuck trying to get my function to load a single object from within a pre set table. for example, I have objects 1,2,3 inside a table and the function will display 1 of those complete with its parameters. Then it will pick 2 from a much larger table of objects.
In my current set up my function just creates every object from the table and places them on top of each other.
Can someone help me as to how to properly do this?
Cheers
Table
local Shapes = {"Triangle", "Square", "Circle"}
Spawning shapes
function spawnShape() shuffleArray(Shapes) for i = 1, #Shapes do local shapeName = Shapes[i] local posX = \_W/2 -- display.contentWidht / 2 local posY = \_H/2 - 100 if shapeName == "Triangle" then Shape = display.newImageRect("Shapes/triangleBlue.png", 35,35) Shape.name = "triangle" physics.addBody(Shape, {isSensor=true}) Shape.x = posX Shape:toFront() Shape.y = posY Shape.alpha = 0 Shape.xScale = 0.1 Shape.yScale = 0.1 --soundDelay = timer.performWithDelay(sfxDelay, playPop1) elseif shapeName == "Square" then Shape = display.newImageRect("Shapes/squareRed.png", 33,33) Shape.name = "square" physics.addBody(Shape, {isSensor=true}) Shape.x = posX Shape:toFront() Shape.y = posY Shape.alpha = 0 Shape.xScale = 0.1 Shape.yScale = 0.1 --enemyMovement2 = transition.to( red, { time=1000, alpha=1} ) else --create green enemy Shape = display.newImageRect("Shapes/circleGreen.png", 35,35) Shape.name = "circle" physics.addBody(Shape, {isSensor=true}) Shape.x = posX Shape:toFront() Shape.y = posY Shape.alpha = 0 Shape.xScale = 0.1 Shape.yScale = 0.1 end end end