Hey guys, could anyone tell me what I’m doing wrong? My games got enemies that spawn randomly through a timer however, when they spawn their images don,t show up, even though the actual spawn is onscreen with collision, its invisible. I’ve set it up so it uses storyboard. Have I set up storyboard assets incorrectly? any help would be awesome, the terminal (Mac) is showing no errors.
Here are some key parts to my setup
local physics = require “physics”
physics.start()
local storyboard = require( “storyboard” )
local scene = storyboard.newScene()
function scene:createScene( event )
print( “Menu: createScene event”)
local screenGroup = self.view
local enemies = display.newGroup()
screenGroup:insert(enemies)
function addEnemy(e)
enemy = display.newImage(‘enemyA.png’)
enemy.y = math.floor(math.random() * (display.contentHeight))
enemy.x = (display.contentWidth)
enemy.name = ‘enemy’
physics.addBody(enemy, { isSensor = true })
enemy.bodyType = ‘static’
enemy.speed = math.random(2,100)
enemies.insert(enemies, enemy)
enemy:addEventListener(‘collision’, collisionHandler)
print(“enemy”)
end
function update(event)
if(enemies.numChildren ~= 0) then
for i = 1, enemies.numChildren do
if(enemies[i] ~= nil) then
enemies[i].x = enemies[i].x - 3
if(enemies[i].x < -200) then
enemies:remove(enemies[i])
display.remove(enemies[i])
changeHealth( 10 )
print(“UFO destroyed”)
end
end
end
end
end
end
function scene:enterScene( event )
print( “GAME: enterScene event” )
Runtime:addEventListener(‘enterFrame’, update)
Runtime:addEventListener(‘enterFrame’, spawn)
end