Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 在循环计数结束时删除动画_Loops_Animation_Sdk_Lua_Coronasdk - Fatal编程技术网

Loops 在循环计数结束时删除动画

Loops 在循环计数结束时删除动画,loops,animation,sdk,lua,coronasdk,Loops,Animation,Sdk,Lua,Coronasdk,我正在使用下面的代码来播放爆炸动画,当动画完成循环计数时,我如何删除它 function showExplotion(event) local sheetData = { width=32, height=32, numFrames=13, sheetContentWidth=128, sheetContentHeight=128 } local mySheet = graphics.newImageSheet( "media/f

我正在使用下面的代码来播放爆炸动画,当动画完成循环计数时,我如何删除它

        function showExplotion(event) 
            local sheetData = { width=32, height=32, numFrames=13, sheetContentWidth=128, sheetContentHeight=128 }
            local mySheet = graphics.newImageSheet( "media/fire.png", sheetData )
              local sequenceData = {
                --{ name = "normalRun", start=1, count=13, loopCount = 1, time=800 }
                { name = "fastRun", frames={ 1,2,4,5,6,7,8,9,10,11,12,13 }, time=800, loopCount = 1 }
            }

            local animation = display.newSprite( mySheet, sequenceData )
            animation.x = event.x
            animation.y = event.y
            animation:play()
        end

您可以将侦听器添加到精灵动画以检测其相位

function showExplotion(event) 


        local sheetData = { width=32, height=32, numFrames=13, sheetContentWidth=128, sheetContentHeight=128 }
        local mySheet = graphics.newImageSheet( "media/fire.png", sheetData )
        local sequenceData = {
            --{ name = "normalRun", start=1, count=13, loopCount = 1, time=800 }
            { name = "fastRun", frames={ 1,2,4,5,6,7,8,9,10,11,12,13 }, time=800, loopCount = 1 }
        }

        local animation = display.newSprite( mySheet, sequenceData )
        animation.x = event.x
        animation.y = event.y
        animation:play()

       local function mySpriteListener( event )

         if ( event.phase == "ended" ) then
              animation:removeSelf()
              animation = nil
         end
      end

       animation:addEventListener( "sprite", mySpriteListener )  

  end

谢谢*动画=零不=零