For instance if you get to 10 balls spawned, then something happens, and if you get to 30 balls spawned then something else will happen.
I have a timer that goes to my ball spawning function five times and this function also has “bs = bs +1”
(at the very beginning I put bs = 0). So I’m thinking from what I learned that this should keep track of all the objects spawned through that one function. Now I made a separate function saying if(bs == 5) then physics.start () or whatever I need but for some reason it doesn’t work. I put up the main segment of my code that the problem should be in.
Greatly appreciating any help.
[lua]
local function gameOperator ()
if (bs == 5) then
local physics = require “physics”
physics.start()
physics.addBody( ball, “dynamic”, { density=3.0, friction=0.5, bounce=0.3 } )
end
end
local function ballSpawn ()
local ball = display.newImageRect (“ball_blue.png”, 100,100)
ball:setReferencePoint (display.CenterReferencePoint)
ball.x = math.random (50, _W - 50); ball.y = math.random (50, _H -400)
function ball:touch(e)
if(ready == true) then
if (e.phase == “ended”) then
clickedBall (self)
end
end
return true;
end
– increase bs every time balls are spawned
bs = bs + 1
ball: addEventListener (“touch”, ball)
ready = true
end[/lua] [import]uid: 35535 topic_id: 9260 reply_id: 309260[/import]