this happening, how resolve?

local composer = require( “composer” )

local scene = composer.newScene()

– include Corona’s “physics” library

local physics = require “physics”

physics.start(); physics.pause()


– forward declarations and other locals

local screenW, screenH, halfW = display.contentWidth, display.contentHeight, display.contentWidth*0.5

local score = 0

local vege = true

function scene:create( event )

– Called when the scene’s view does not exist.

– 

– INSERT code here to initialize the scene

– e.g. add display objects to ‘sceneGroup’, add touch listeners, etc.

local sceneGroup = self.view

– create a grey rectangle as the backdrop

local background = display.newRect( 0, 0, screenW, screenH )

background.anchorX = 0

background.anchorY = 0

background:setFillColor( 2 )

local playerScore = display.newText("Score: "…score, 140, 60, native.systemFont, 50);

playerScore:setTextColor(0, 0, 0);

  

  

  local kor1 = display.newCircle(90, 240, 50)

  local kor2 = display.newCircle(230, 240, 50)

  

  – make a crate (off-screen), position it, and rotate slightly

 function csere1(event) 

  r = math.random(0,1) 

g = math.random(0,1) 

b = math.random(0,1) 

kor1:setFillColor(r,g, B)

  kor1.strokeWidth = 5

  kor1:setStrokeColor(0, 0, 0)

 end

local s1 = math.random(400,1100)

timer.performWithDelay(s1, csere1, 0)

 function csere2(event) 

  r = math.random(0,1) 

g = math.random(0,1) 

b = math.random(0,1) 

kor2:setFillColor(r,g, B)

  kor2.strokeWidth = 5

  kor2:setStrokeColor(0, 0, 0)

 end

local s = math.random(500,1000)

 timer.performWithDelay(s, csere2, 0)

 function kor1:touch(event)

   if (event.phase == “began”) and ( kor1.fill.r == 1 and kor1.fill.g == 0 and kor1.fill.b == 0 ) then 

   score = score + 1;

   playerScore.text = "Score: " … score

   else

   vege = false 

   print"vege"

   end

   

 end

 kor1:addEventListener(“touch”,kor1)

  

  function kor2:touch( event )

    if (event.phase == “began”) and ( kor2.fill.r == 0 and kor2.fill.g == 0 and kor2.fill.b == 1 ) then 

    score = score + 1;

    playerScore.text = "Score: " … score

   elseif (event.phase == “ended”) then

    composer.removeScene( “level1” )

    composer.gotoScene( “gameover” )

    end

  end

 kor2:addEventListener(“touch”,kor2)

– define a shape that’s slightly shorter than image bounds (set draw mode to “hybrid” or “debug” to see)

– all display objects must be inserted into group

sceneGroup:insert( background )

end

function scene:show( event )

local sceneGroup = self.view

local phase = event.phase

if phase == “will” then

– Called when the scene is still off screen and is about to move on screen

elseif phase == “did” then

– Called when the scene is now on screen

– 

– INSERT code here to make the scene come alive

– e.g. start timers, begin animation, play audio, etc.

physics.start()

end

end

function scene:hide( event )

local sceneGroup = self.view

local phase = event.phase

if event.phase == “will” then 

   – kor2:removeEventListener(“touch”, kor2)  

    – Called when the scene is on screen and is about to move off screen

– INSERT code here to pause the scene

– e.g. stop timers, stop animation, unload sounds, etc.)

physics.stop()

elseif phase == “did” then

– Called when the scene is now off screen

    --composer.removeScene( “level1” )

    --composer.gotoScene( “gameover” )

end

end

function scene:destroy( event )

  – Called prior to the removal of scene’s “view” (sceneGroup)

– 

– INSERT code here to cleanup the scene

  – e.g. remove display objects, remove touch listeners, save state, etc.

local sceneGroup = self.view

package.loaded[physics] = nil

physics = nil

end


– Listener setup

scene:addEventListener( “create”, scene )

scene:addEventListener( “show”, scene )

scene:addEventListener( “hide”, scene )

scene:addEventListener( “destroy”, scene )


return scene