Hi there. Nice to see such a huge community out here but sadly but I came here with a problem which I can’t solve myself. I just trying to add eventListener to a object, but I get error mentioned in the title. Here is my whole code at this point :
-- housekeeping stuff display.setStatusBar(display.HiddenStatusBar) local centerX = display.contentCenterX local centerY = display.contentCenterY -- set up forward references local spawnEnemy -- preload audio -- create play screens local function createPlayScreen() local bg = display.newImage("background.png") bg.y = 130 bg.x = 100 bg.alpha = 0 local planet = display.newImage("planet.png") planet.x = centerX planet.y = display.contentHeight +60 planet.alpha = 0 transition.to( bg, { time = 2000, alpha = 1, y = centerY, x = centerX } ) local function showTitle() local gametitle = display.newImage("gametitle.png") gametitle.alpha = 0 gametitle:scale (4, 4) transition.to( gametitle, { time = 500, alpha = 1, xScale = 1, yScale = 1 }) spawnEnemy() end transition.to( planet, { time = 2000, alpha = 1, y = centerY, onComplete = showTitle } ) end -- game functions local function shipSmash(event) local obj = event.target display.remove( obj ) end local function spawnEnemy() local enemy = display.newImage("beetleship.png") enemy.x = math.random(20, display.contentWidth - 20) enemy.y = math.random(20, display.contentHeight - 20) enemy:addEventListener ( "tap", shipSmash ) end local function startGame() end local function planetDamage() end local function hitPlanet(obj) end createPlayScreen() startGame()
And here is the errors screen I’m getting :
Thank you guys for any responses