I’m spawning a ‘bomb’ sprite and listening to the event.phase for ‘ended’ upon which I destroy it.
It works as expected - most of the time.
Every now and then (~1 in 30 spawns), the phase never reaches ‘ended’ because the animation never plays past frame 1.
So the sprite appears on screen and shows the first frame. And is never destroyed.
Any thoughts on why the animation would stop on frame 1 ?
I guess I could also attach a timer to fire after the animation should be finished and check the frame and then destroy, but it’d be better to find out what is going on.
function spawnBomb(x, y)
local bomb = display.newSprite( bombImageSheet, bombSequenceData )
bomb.x, bomb.y = x, y
bomb:setSequence('detonate')
bomb:play()
local p = bomb.isPlaying
print(p) -- this is always 'true'
bomb:addEventListener( "sprite", bombDone )
local explodeChannel = audio.play( bombSFX, { loops=0 } )
impulseBlocks(x, y)
end
function bombDone (event)
if ( event.phase == "ended" ) then
local obj = event.target
print("det finish: " .. obj.x)
display.remove ( obj )
obj = nil
end
end
[import]uid: 186251 topic_id: 33396 reply_id: 333396[/import]