Hello again everyone. I am eleven years old and a novice at Corona. I have a large amount of code for creating an invisible explosion. However, after adding the final event listener, terminal says that it is trying to call method “getOrCreateTable” and says it is a nil value. Oddly, I never included tables in my code. It does the strack traceback thing and says
[C]: in function ‘getOrCreateTable’
?: in function ‘addEventListener’
One thing to note is that when I replace ‘background’ in the final event listener with ‘Runtime’, it replaces all instances of ‘getOrCreateTable’ with ‘respondsToEvent’. Here is my code:
[code]
local physics = require(“physics”)
physics.start()
physics.setScale(40)
display.setStatusBar( display.HiddenStatusBar )
local background = display.newImage( “background.png”, 0, 0, true )
background.x = display.contentWidth / 2
background.y = display.contentHeight / 2
local floor = display.newImage( “floor.png”, 0, 280, true )
physics.addBody( floor, “static”, { friction = 0.5 } )
local function onLocalCollision( self, event )
if ( event.phase == “began” and self.myName == “circle” ) then
local forcex = event.other.x-self.x
local forcey = event.other.y-self.y-20
if (forcex < 0) then
forcex = 0-(80+forcex)-12
else
forcex = 80-forcex+12
end
event.other:applyForce( forcex, forcey, self.x, self.y )
end
end
local crates = {}
for i = 1, 5 do
for j = 1, 5 do
crates[i] = display.newImage( “crate.png”, 140 + (i*50), 220 - (j*50) )
physics.addBody( crates[i], { density = 0.2, friction = 0.1, bounce = 0.1 } )
end
end
local circle = “”
local function setBomb ( event )
if(event.phase == “began”) then
circle = display.newCircle( event.x, event.y, 80 )
circle.myName = “circle”
circle.setFillColor( 0, 0, 0, 0 )
physics.addBody( circle, “static”, {isSensor = true} )
circle.collision = onLocalCollision
circle.addEventListener( “collision”, circle )
end
if(event.phase == “ended”) then
circle.removeSelf()
end
end
background.addEventListener( “touch”, setBomb )
physics.setDrawMode( “hybrid” ) [import]uid: 82408 topic_id: 15120 reply_id: 315120[/import]
[import]uid: 82408 topic_id: 15120 reply_id: 56074[/import]