OK let me brief up the code below is different about enemy ships hovering and automatically firing.
--setting physics local physics= require( "physics") physics.start() physics.setGravity(0,0) local w,h=display.contentWidth,display.contentHeight -- Hide status bar display.setStatusBar( display.HiddenStatusBar ) -- Seed the random number generator math.randomseed( os.time() ) --initializing variables local enemyTable={} local numEnemy=0 local mainGroup=display.newGroup() local function loadEnemy() numEnemy=#enemyTable+1 local newEnemy=display.newRect(mainGroup,w/2,20+(math.random(1,3)\*30),30,30) newEnemy:setFillColor(1,0.2,0.2,1) table.insert(enemyTable,newEnemy) physics.addBody( newEnemy,"dynamic" ) newEnemy.myName="enemy" mewEnemy:setLinearVelocity((math.random(10,70)),0) local function fireEnemyBullet() local newEnemyBullet=display.newImage(mainGroup,"enemyBullet.png",newEnemy.x,newEnemy.y) physics.addBody( newEnemyBullet,"dynamic" ) newEnemyBullet.isBullet=true newEnemyBullet.myName="enemyBullet" newEnemyBullet.toBack()--keeps below the enemy shipBlast transition.to( newEnemyBullet,{y=h+40,time=700,onComplete=function() display.remove(newEnemyBullet) end }) end fireEnemyBullet() end local function gameLoop() loadEnemy() for i=#enemyTable,1,-1 do--#tells the number of object in enemyTable local thisEnemy=enemyTable[i] if(thisEnemy.x\>=w+40) then display.remove( thisEnemy ) table.remove( enemyTable, i ) end end end timer.performWithDelay( 500, gameloop ,0 )
The code here is only part of a big program but since it was not working I tried to tried to break it down to small section to look for the actual fault now when I compile the above program it shows no error but it show a dark screen help me out