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

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/cowell/Desktop/Corona Dev/corona-shooter/d/ui.lua:28>
?: in function <?:214>

The code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
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

Nevermind, had an error elsewhere..

views:1390 update:2011/10/13 9:25:17
corona forums © 2003-2011