how to remove a group when scene changes

hi i am having a bit problem in removing images in a displaygroup.i created two functions one to 

keep adding an image every second using a timer which looked like this

function addenemy()

 enemy=display.newImageRect(“imageofenemy.png”,80,80);

enemy.x=centerX+100;

enemy.y=centerY;

group1:insert(enemy);

end

enemyTimer = timer.performWithDelay(1000, addenemy,11);

(canceled the timer in hide scene  in phase==“will”)


and another function to move the enemy

 function move()

for a = group1.numChildren,1,-1  do

if(group1[a].y < 700) then

group1[a].y = group1[a].y +18

else 

group1:remove(group1[a])

end

end

end

moveTimer=timer.performWithDelay(2, move, -1);

(canceled the timer in hide scene in phase==“will” )


when i change scene on collision between player and enemy the enemy keeps appearing even 

when i changed the scene.

function addenemy() &nbsp; enemy=display.newImageRect("imageofenemy.png",80,80); enemy.x=centerX+100; enemy.y=centerY; group1:insert(enemy); end &nbsp; enemyTimer = timer.performWithDelay(1000, addenemy,11); (canceled the timer in hide scene &nbsp;in phase=="will") ---------------------------- and another function to move the enemy function move() for a = group1.numChildren,1,-1 &nbsp;do if(group1[a].y \< 700) then group1[a].y = group1[a].y +18 else&nbsp; group1:remove(group1[a]) end end end moveTimer=timer.performWithDelay(2, move, -1); (canceled the timer in hide scene in phase=="will" )

Tweaked formatting for easier review.

keeps appearing even 

when i changed the scene.

Are additional enemies appearing, or just the ones you have aren’t being removed?

function addenemy() &nbsp; enemy=display.newImageRect("imageofenemy.png",80,80); enemy.x=centerX+100; enemy.y=centerY; group1:insert(enemy); end &nbsp; enemyTimer = timer.performWithDelay(1000, addenemy,11); (canceled the timer in hide scene &nbsp;in phase=="will") ---------------------------- and another function to move the enemy function move() for a = group1.numChildren,1,-1 &nbsp;do if(group1[a].y \< 700) then group1[a].y = group1[a].y +18 else&nbsp; group1:remove(group1[a]) end end end moveTimer=timer.performWithDelay(2, move, -1); (canceled the timer in hide scene in phase=="will" )

Tweaked formatting for easier review.

keeps appearing even 

when i changed the scene.

Are additional enemies appearing, or just the ones you have aren’t being removed?