Listeners crashing my project?

I’m in the process of porting my project over to the director class. For right now I have a screen that has a level select screen that redirects to levels themselves. The game doesn’t really do anything just yet, so I’m pretty sure my listeners are whats hanging me up. Sorry if this is a noob question (I’m new to Corona and the Director class :slight_smile: )

Errors im getting:
Runtime error
assertion failed!
stack traceback:
[C]: ?
[C]: in function ‘assert’
?: in function ‘getOrCreateTable’
?: in function ‘addEventListener’
?: in function ‘addEventListener’
…owell/Desktop/Corona Dev/corona-shooter/d/level1.lua:164: in function ‘initVars’
…owell/Desktop/Corona Dev/corona-shooter/d/level1.lua:191: in function ‘new’
…ell/Desktop/Corona Dev/corona-shooter/d/director.lua:268: in function ‘loadScene’
…ell/Desktop/Corona Dev/corona-shooter/d/director.lua:387: in function ‘changeScene’
…well/Desktop/Corona Dev/corona-shooter/d/screen1.lua:31: in function ‘onEvent’
…rs/cowell/Desktop/Corona Dev/corona-shooter/d/ui.lua:88: in function <…rs dev>
?: in function <?:214>

The code:
[lua]module(…, package.seeall)
local physics = require(“physics”)
---------------------------------------------------------------
– GROUPS
---------------------------------------------------------------

local localGroup = display.newGroup()
local gameLayer = display.newGroup()
local enemiesLayer = display.newGroup()

---------------------------------------------------------------
– DISPLAY OBJECTS
---------------------------------------------------------------

local background = display.newRect(0,0,320,480)
local player = display.newImage(“assets/graphics/player.png”)
local player2 = display.newImage(“assets/graphics/player.png”)
---------------------------------------------------------------
– LISTENERS
---------------------------------------------------------------

local function onCollision(self, event)
– Bullet hit enemy
if self.name == “bullet” and event.other.name == “enemy” and gameIsActive then
– Increase score
score = score + 1
scoreText.text = score

– Play Sound
audio.play(sounds.boom)

table.insert(toRemove, event.other)


end
end

--------------------------------------------------------------------------------
– Basic controls
--------------------------------------------------------------------------------
local function playerMovement(event)
– Doesn’t respond if the game is ended
if not gameIsActive then return false end

– Only move to the screen boundaries
if event.x >= halfPlayerWidth and event.x <= display.contentWidth - halfPlayerWidth or event.y >= halfPlayerHeight and event.y <= display.contentHeight - halfPlayerHeight then
– Update player x axis
player.x = event.x
player.y = event.y
end
end
---------------------------------------------------------------
– INIT VARS
---------------------------------------------------------------

local function initVars ()
print(“init vars got HIT!!”)

audio.setMaxVolume( 0.85, { channel=1 } )

physics.start()
physics.setGravity(0, 20)
local sounds
sounds = {
pew = audio.loadSound(“assets/sounds/pew.wav”),
boom = audio.loadSound(“assets/sounds/boom.wav”),
gameOver = audio.loadSound(“assets/sounds/gameOver.wav”)
}

physics.addBody(player, “dynamic”, {bounce = 0.1})
physics.addBody(player2, “static”, {bounce = 0})
--physics.addBody(rect, “static”)


-----------------------------------
– Inserts
-----------------------------------

localGroup:insert(background)
--gameLayer:insert(scoreText)
localGroup:insert(enemiesLayer)


-----------------------------------
– Listeners
-----------------------------------

--background:addEventListener( “touch” , touched )
Runtime:addEventListener(“enterFrame”, gameLoop)
– Player will listen to touches
player:addEventListener(“touch”, playerMovement)
player.collision = onCollision
player:addEventListener(“collision”, player)


end –
--------------------------------------------------------------------------------
– Take care of collisions

local function gameLoop(event)
if gameIsActive then
– Remove collided enemy planes
for i = 1, #toRemove do
toRemove[i].parent:remove(toRemove[i])
toRemove[i] = nil
end

end
end[/lua]

I’m actually using some example code for elsewhere just to kind of get a feel for what’s going on. I’ve stripped out a lot of stuff I thought was unrelated to my errors. Any thoughts?

Thanks

[import]uid: 52208 topic_id: 9266 reply_id: 309266[/import] </…rs>

Nevermind, had an error elsewhere… [import]uid: 52208 topic_id: 9266 reply_id: 33869[/import]