after following a certain tutorial i get an error. and i still cant figure it out.
the tutorial link :
http://www.youtube.com/watch?v=NOgkL0LCiuI&list=PL2zG6R7mENQf9NIInCPquC7hQFkH_IqMy
and the error i get is
Runtime error
…t-master\spaceinvadersstart-master\Classes\enemy.lua:59: attempt to index upvalue ‘bomb’ (a boolean value)
stack traceback:
[C]: ?
…t-master\spaceinvadersstart-master\Classes\enemy.lua:59: in function ‘dropBomb’
where the error is i made it bold and underlined it and the code where it comes from is below. i hope that someone can help me out of this. i thank you in advance
enemy.lua
– enemy.lua
– Create the Enemy’s and there functionality
local bomb = require(“Classes.bomb”)
local enemys = {}
local enemys_mt = { __index = enemys }
local scene = scene – make scene a local variable for quick reference
function enemys:new() – constructor, just creates the class, nothing else
local group = {}
return setmetatable( group, enemys_mt )
end
function enemys:init(xloc, yloc) --initializer, add any variables or images here
– create attributes
self.image = display.newImage(“Assets/Enemy.png”)
self.image.x = xloc
self.image.y = yloc
self.movement = 1
self.rightHit = 0
self.leftHit = 0
self.numberOfWallHits = 0
physics.addBody( self.image, “dynamic” )
end
function enemys.enterFrame(self, event)
self.image.x = self.image.x + self.movement
end
local function dropBomb( event, self )
timer.cancel( self.clock )
local newBomb = bomb:new()
newBomb:init(self.image.x - 10, self.image.y + 5)
newBomb:start( )
end
function enemys:start() — Create Listeneres, start things that need to be ‘running’
Runtime:addEventListener( “enterFrame”, self ) – runtime listener to move the enemy
self.image:addEventListener( “collision”, self ) – collide with another physics body
scene:addEventListener( “hit_rightWall_event”, self )
scene:addEventListener( “hit_leftWall_event”, self )
– the bomb code
local delay = math.random(2000, 15000)
self.clock = timer.performWithDelay( delay, function (event) dropBomb(event, self) end, 1)
end
return enemys
and the bomb.lua
local bomb = {}
local bomb_mt = { __index = bomb }
local scene = scene – make scene a local variable for quick reference
function bomb:new() – constructor, just creates the class, nothing else
local group = {}
return setmetatable( group, bomb_mt )
end
function bomb:init(xloc, yloc) --initializer, add any variables or images here
– create attributes
self.bomb =display.newGroup ( )
local bomb1 = display.newRect( self.bomb,5,5,5,15)
bomb1:setFillColor ( 247, 255, 94 )
local bomb1 = display.newRect( self.bomb,0,0,15,5)
bomb1:setFillColor ( 252, 0, 20 )
self.bomb.x = xloc
self.bomb.y = yloc
physics.addBody( self.bomb, “dynamic” )
end
function bomb:enterFrame()
– body
self.bomb.y = self.bomb.y + 10
end
function bomb:start() — Create Listeneres, start things that need to be ‘running’
Runtime:addEventListener( “enterFrame”, self )
end
return bomb