Hi, I’m trying to create multiple objects from a group I created
Using the below code it only creates one fly instead of the 10, where am I going wrong?
numFlies = 10 halfW = display.viewableContentWidth / 2 halfH = display.viewableContentHeight / 2 for i=1,numFlies do local flygroup = display.newGroup() flygroup:insert(flying, true) flygroup:insert(splat, true) splat.isVisible = false -- add physics to the fly physics.addBody( flygroup) flygroup.gravityScale = 0 flygroup:translate( halfW + math.random( -100, 100 ), halfH + math.random( -100, 100 ) ) -- set velocity in pixels per second. flygroup:setLinearVelocity(100,0) flygroup:addEventListener( "touch", buttonListener ) end