hello all,
here is my code,I call the addenermy function periodically,
but it sometimes successful,sometimes error as picture,
the red line below is line 156,
thanks for your help
timesource = timer.performWithDelay(math.random(800,1200),addenermy,0)
function addenermy()
local j = math.random(1,10)
local str1 = “images/monster/mon”…tostring(j)…".png"
local x,y = math.random(50,_W-50),-200
local mon = display.newImage(str1)
local i = math.random(1,5)
local str = “images/small/c_”…kindofgesture[i]…".png"
local core = display.newImage(str)
local enermy = display.newGroup()
enermy:insert(mon)
enermy:insert(core)
enermy.x,enermy.y = x,y
enermy.type = kindofgesture[i]
physics.addBody(enermy,{radius = 50})
enermy:setLinearVelocity(math.random(0,50),math.random(200,400))
enermygroup:insert(enermy)
end