i copied a word to word code but still get an error

i was following a guide of a youtuber and copied all of his code but i keep getting an error in the end 

main.lua:64:attempt to call method ‘addEventlistener’ (a nil value)

stack traceback:

main.lua:64: in function ‘addNewBalloonOrBomb’

main.lua:70: in main chuck 

plz help this was my first time coding and i have no idea whats going on 

code 


– main.lua


– Your code here

local physics = require( “physics” )

physics.start()

– start physics engine 

halfw = display.contentWidth*0.5

halfh = display.contentHeight*0.5

–set location of halfw2 at 0.5 of screen width 

– set location of halfh at 0.5 of screen height both at the center 

local bkg = display.newImage(“sky.jpg”, halfw, halfh)

– loads the image sky into the backgorund 

score = 0

scoretext = display.newText(score, halfw ,10)

– sometimes its better to rewrite the code

–displays a score of zero on the screen 

local function balloonTouched(event)

  if ( event.phase == “began” ) then

    Runtime:removeEventListener( “enterFrame”, event.self )

    event.target:removeSelf()

    score = score + 1

    scoreText.text = score

  end

end

local function bombTouched(event)

  if ( event.phase == “began” ) then

    Runtime:removeEventListener( “enterFrame”, event.self )

    event.target:removeSelf()

    score = math.floor(score * 0.5)

    scoreText.text = score

  end

end

local function offscreen(self, event)

  if(self.y == nil) then

    return

  end

  if(self.y > display.contentHeight + 50) then

  Runtime:removeEventListener( “enterFrame”, self )

  self:removeSelf()

end 

end

– hmmmmmmmm

local function addNewBalloonOrBomb()

  local startX = math.random(display.contentWidth*0.1,display.contentWidth*0.9)

  if(math.random(1,5)==1) then

    – BOmb!

  local bomb = display.newImage( “bomb.jpg”, startX, -300)

    physics.addBody( bomb )

    bomb.enterFrame = offscreen

    Runtime:addEventListener( “enterFrame”, bomb )

    bomb:addEventListener( “touch”, bombTouched )

  else

    – Balloon

    local balloon = display.newImage( “red_balloon.jpg”, startx, -300)

    physics.addBody( balloon )

    balloon.enterFrame = offscreen

    Runtime:addEventlistener( “enterFrame”, balloon )

    balloon:addEventListener( “touch”, balloonTouched )

  end

end

    

addNewBalloonOrBomb()

timer.performwithdelay( 500, addNewBalloonOrBomb, 0 )

What is line 64?

Looking in the console log window, are there any other error or warning messages like an image not found?

I suspect this is the line of code:

Runtime:addEventlistener( "enterFrame", balloon )

Lua is a case-sensitive language. There is no API call named “addEventlistener”, but there is “addEventListener”. Notice the difference in capitalization?

Rob

What is line 64?

Looking in the console log window, are there any other error or warning messages like an image not found?

I suspect this is the line of code:

Runtime:addEventlistener( "enterFrame", balloon )

Lua is a case-sensitive language. There is no API call named “addEventlistener”, but there is “addEventListener”. Notice the difference in capitalization?

Rob