I got the following code from a different web site -
function spawnEnemy() local enemypics = {"beetleship.png","octopus.png", "rocketship.png"} local enemy = display.newImage(enemypics[math.random (#enemypics)]) enemy:addEventListener ( "tap", shipSmash ) if math.random(2) == 1 then enemy.x = math.random ( -100, -10 ) else enemy.x = math.random ( display.contentWidth + 10, display.contentWidth + 100 ) enemy.xScale = -1 end enemy.y = math.random (display.contentHeight) enemy.trans = transition.to ( enemy, { x=centerX, y=centerY, time=math.random(2500-speedBump, 4500-speedBump), onComplete=hitPlanet } ) speedBump = speedBump + 100 end
enemypics is a set of images that randomly spawn and move/fly towards the center of the screen.
My question is how do I change from still images to sprite sheets? i would like to use the same code as close to its original form as possible. This is learning/study code for me so I am experimenting.
I appreciate any help. Thanks.
