local ufo = display.newImageRect("ufo2.png" ,100,90) ufo.x = 100 ufo.y = 100 local beam = display.newImageRect("Beam.png" ,90,200) beam.isVisible = false local obj = display.newImageRect ("Icon.png",70,70) obj.x = 100 obj.y = 300 local sheetData = {width = 100,height = 90,numFrames = 8,sheetContentWidth = 200,sheetContentHeight = 360} local mySheet = graphics.newImageSheet ("ufo.png",sheetData) local sequenceData = {name = "ufo1",start = 1,count = 8,time = 950,loopcount = 0,looDirection = "forward"} local ufo1 = display.newSprite (mySheet,sequenceData) ufo1.x = 500 ufo1.y = 100 ufo1Intro = transition.to (ufo1, {time = 1500,x = 240}) ufo1.isVisible = false function beamOn (event) if event.phase == "began" then beam.isVisible = true beam.x = ufo.x beam.y = ufo.y + 110 if beam.x \< 50 then beam.isVisible = false end end end ufo:addEventListener ("touch",beamOn) function beamOff (event) if event.phase == "ended" then beam.isVisible = false end end ufo:addEventListener ("touch",beamOff) function onCollision (event) if ( event.phase == "began" and beam.y == obj.y - 90 ) then ufo1:play() ufo1.isVisible = true if (event.phase == "ended") then ufo1:pause() ufo1.isVisible = false end end end ufo:addEventListener("touch",onCollision)
Here it is. The ufo1 (the animation) doesn’t pause and doesn’t disaper. Also how can I make the animation play and stop and disaper when it’s finished?