Why doesn't work?Please someone assist and Redeemer of the world!

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(900,1000)

 timer.performWithDelay(1200, 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

   vege = true

   print"jo"

   else 

   composer.gotoScene(“gameover”, “slideLeft”, 800)

   print"rosz"

   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

    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

composer.removeScene( “menu” )

    – 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 phase == “began” then 

kor1:removeEventListener( “touch”, kor1 )

    kor2:removeEventListener( “touch”, kor2 )

    timer.stop( csere1 ); csere1 = nil;

    timer.stop( csere2 ); csere2 = nil;

    kor1:removeSelf(); kor1 = nil ;

    kor2:removeSelf(); kor2 = nil ; 

    

   

   – composer.removeScene( “level1” )

    --composer.removeScene(“level1”)

    

    --local function gameover(event) 

    --if (event.phase == “began”) and (vege == false) then

    --composer.removeScene(“level1”)

    --composer.gotoScene(“gameover”, slideDown, 200)  

    --end

 —end

    –    composer.removeScene(“level1”)

    

    –  timer.cancel(csere2)

    --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

    --composer.removeScene( “level1” )

    

    --composer.gotoScene(“gameover”)

    – Called when the scene is now off screen

    --composer.removeScene( “level1” )

    --composer.gotoScene( “gameover” )

end

end

function scene:destroy( event )

–composer.removeScene(“level1”)

  – 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

Hi @tokosbex,

Generally, you will not receive much assistance from the community if you simply ask “why doesn’t this work?” and post a giant block of code. You should be more specific and mention exactly what “should work” and what you’re attempting to do.

Also, minimize your code to only the essential aspects… other developers (and staff) typically can not take the time to look through a big dump of code to figure out what is causing problems.

Finally, please surround your code with “lua” tags for clarity in the forums:

[lua] -- your code [/lua]

Best regards,

Brent

Thank you , I rezolve problem but the next question I remember your suggestion!

Hi @tokosbex,

Generally, you will not receive much assistance from the community if you simply ask “why doesn’t this work?” and post a giant block of code. You should be more specific and mention exactly what “should work” and what you’re attempting to do.

Also, minimize your code to only the essential aspects… other developers (and staff) typically can not take the time to look through a big dump of code to figure out what is causing problems.

Finally, please surround your code with “lua” tags for clarity in the forums:

[lua] -- your code [/lua]

Best regards,

Brent

Thank you , I rezolve problem but the next question I remember your suggestion!