What is the best way to destroy sprite animations? Right now I have to estimate the time to finish then destroy.
function kill_animation()
Sprite:removeSelf()
Sprite=nil
end
Sprite:play
timer.performWithDelay( 1000, kill_animation, 1 )
What is the best way to destroy sprite animations? Right now I have to estimate the time to finish then destroy.
function kill_animation()
Sprite:removeSelf()
Sprite=nil
end
Sprite:play
timer.performWithDelay( 1000, kill_animation, 1 )
Use a ‘sprite’ listener:
local myListener = function ( self, event ) if( event.phase == "ended" ) then self:removeEventListener( "sprite" ) display.remove( self ) end return true end local myAnim = display.newSprite( ... ) myAnim.sprite = myListener myAnim:addEventListener( "sprite" ) myAnim:play() myAnim = nil
Thank you for the edit I was confused at first. I will try to implement this today thanks!
Use a ‘sprite’ listener:
local myListener = function ( self, event ) if( event.phase == "ended" ) then self:removeEventListener( "sprite" ) display.remove( self ) end return true end local myAnim = display.newSprite( ... ) myAnim.sprite = myListener myAnim:addEventListener( "sprite" ) myAnim:play() myAnim = nil
Thank you for the edit I was confused at first. I will try to implement this today thanks!