function enemys.hit_rightWall_event(self, event, movement) -- should be called when 'Enemy' hits the right wall self.movement = -self.movement self.numberOfWallHits = self.numberOfWallHits + 1 checkNumHits(self) end function enemys.hit_leftWall_event(self, event, movement) -- should be called when 'Enemy' hits the left wall self.movement = -self.movement self.numberOfWallHits = self.numberOfWallHits + 1 checkNumHits(self) end function enemys.collision(self, event, movement) if event.phase == 'began' then if event.other.name == "leftWall" then scene:dispatchEvent{name="hit_leftWall_event"} elseif event.other.name == "rightWall" then local message = {name="hit_rightWall_event"} scene:dispatchEvent{name="hit_rightWall_event"} elseif event.other.name == "floorWall" then loadAd() elseif event.other.name == "bullet" then --if(enableSound) then enemyShotChan = audio.play(shot,{channel=7 }) -- end event.target:removeSelf() removeArrayItem(self) timer.cancel(self.clock) scene:dispatchEvent{name="enemyDead"} Runtime:removeEventListener( "enterFrame", self ) self.image:removeEventListener( "collision", self ) --DISPATCHING AND NULLING THE INVADER scene:removeEventListener('hit_rightWall_event', self) scene:removeEventListener('hit_leftWall_event', self) scene:removeEventListener('hit_floorWall_event',self) if self.image.y ~= drop then local explosion2 = display.newSprite(budSprites2.sheets.explosion, budSprites2.sequences.explosion) explosion2:scale(1.5, 1.5) explosion2:play() explosion2.x, explosion2.y = self.image.x, self.image.y timer.performWithDelay(260, function() if explosion2.removeSelf then explosion2:removeSelf() end end ) end local currentScore = getScores( ) -- EFM SCORES - Extract scores from enemies and add to current score local myValue = self.myValue --print("Bang you got: ", myValue, " points" ) currentScore = currentScore + myValue setScores( currentScore ) end end end