sprite.play does not always work ?

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]

Maybe this will help somebody else:

The problem still exists, but I ‘patched’ it by adding each bomb to a table, creating a timer (via a closure) to fire after the sprite animation should be finished, and if the sprite still exists in the table, then destroy it.

So it’s funky, having to create all those timers, but if I can’t figure out why the animation occasionally freezes on frame 1 then this patch approach will have to do.
[import]uid: 186251 topic_id: 33396 reply_id: 132776[/import]

Maybe this will help somebody else:

The problem still exists, but I ‘patched’ it by adding each bomb to a table, creating a timer (via a closure) to fire after the sprite animation should be finished, and if the sprite still exists in the table, then destroy it.

So it’s funky, having to create all those timers, but if I can’t figure out why the animation occasionally freezes on frame 1 then this patch approach will have to do.
[import]uid: 186251 topic_id: 33396 reply_id: 132776[/import]