Here is my code to start off:
numTrumps=100
local function startGame()
myTrump=display.newImageRect("tp.png",25,25)
myTrump.x=Random(50,_W-50)
myTrump.y=(_H+10)
physics.addBody(myTrump,"dynamic",{density=.1,friction=0,bounce=.9,radius=9})
function myTrump:touch(event)
if(timeLeft~=false) then
if (playerReady==true) then
if(event.phase=="ended") then
removeTrumps(self)
end
end
end
end
myTrump:addEventListener("touch",myTrump)
trumps=trumps+1
if(trumps==numTrumps) then
gameTimer=timer.performWithDelay(1000,countDown,totalTime)
else
playerReady=false
end
end
local gameTimer=timer.performWithDelay(20,startGame,numTrumps)
local function Restart(event)
if "began"==event.phase then
if(timeLeft~=false) then
timer.cancel(gameTimer)
gameTimer1=timer.performWithDelay( 20, ByeTrump, 96)
end
end
if "moved"==event.phase then
end
if "ended"==event.phase then
composer.gotoScene("restarttest")
end
end
function ByeTrump()
display.remove(myTrump)
end
So basically the startGame function is repeated 100 times since numTrumps=100 so each time a new image of the same object (myTrump) is created. Once i restart i want to remove the copies of that object so i made a function (ByeTrump) in which one of the myTrump's are removed, and i repeated that 96 times by making another gametimer in restart function. I made 96 disappear not 100 for testing purposes but in my game you have 20 seconds to touch as many of the 100 myTrumps possible and upon touching they are gone.Once 20 seconds is up you can no longer touch them so you have to restart.
So my problem is when i click restart only one of the myTrump's disappear not the remaining 99 (i am not touching any of the myTrumps in the 20 seconds for testing purposes).So when the new 100 myTrumps come after restarting they collide with the ones from the last round even though the last ones aren't visible anymore its like they are invisible a=but still colliding with the new ones.