how to remove spritesheet properly

This is a long running issue I have been having.

I found an example of some code which did what I required, it was the “balloon pop” by Jesse Warden.
It shows how when an object is touched (popped) it plays a sprite sheet.

Now I used some of this code to do what I required but was having problems with the last frame of the spritesheet being kept on screen which resulted in a black box.

I thought I would review the code again in an attempt to correct what I had done wrong.
I put a background image on the balloon pop example to check if the issue was there too, it was.

So my question is how can I remove this last frame after the animation has finished?
Here is my code using some of Jesse’

local leaf = display.newImage( "images/leafs.png" )  
physics.addBody(leaf, "dynamic")  
local w,h = display.viewableContentWidth, display.viewableContentWidth  
leaf.myName = "leaf"  
leaf:addEventListener("collision", leaf)  
  
transition.from( leaf, { time=4000, x=(w+400), y=(h-300),onComplete=removeObject})  
  
require "sprite"  
  
 function newExplosionSprite()  
 local explosion = sprite.newSprite(explosionSet)  
 explosion:prepare("default")  
 explosion.isHitTestable = false  
 return explosion  
end  
  
--explosion sprite removal  
function onBoomEnd(event)  
 event.target:removeSelf()  
end  
  
--end required explosion--  
  
function leaf:collision (event)  
 local leaf = event.target  
 leaf.isVisible = false  
 local explosion = newExplosionSprite()  
 explosion.x = leaf.x  
 explosion.y = leaf.y  
 explosion:addEventListener("end", onBoomEnd )  
 explosion:play()  
 event.target:removeSelf() --removes leaf from screen  
  
end  
local function init()  
 explosionSpriteSheet = sprite.newSpriteSheet("images/BigExplosion.png", 82, 117)  
 explosionSet = sprite.newSpriteSet(explosionSpriteSheet, 1, 18)  
 sprite.add(explosionSet, "default", 1, 18, 200, 1)  
  
end  
  
init()  

any help appreciated. [import]uid: 127675 topic_id: 30262 reply_id: 330262[/import]

Ok, I resolved the issue.
However I have to say I feel a little stupid; having worked with adobe flash,photoshop,illustrator everyday for many years it came down to my sprite sheet not having a transparent background…doh!
How I missed that I don’t know, perhaps I am getting caught up in the code.

Rock on ! [import]uid: 127675 topic_id: 30262 reply_id: 121243[/import]

Hey, @bubblebobble, don’t feel stupid. And, yeah, rock on! We all have a moment like that, and I’m glad to see you sorted your issue and posted it as such.

Cheers,
Naomi [import]uid: 67217 topic_id: 30262 reply_id: 121294[/import]

Ok, I resolved the issue.
However I have to say I feel a little stupid; having worked with adobe flash,photoshop,illustrator everyday for many years it came down to my sprite sheet not having a transparent background…doh!
How I missed that I don’t know, perhaps I am getting caught up in the code.

Rock on ! [import]uid: 127675 topic_id: 30262 reply_id: 121243[/import]

Hey, @bubblebobble, don’t feel stupid. And, yeah, rock on! We all have a moment like that, and I’m glad to see you sorted your issue and posted it as such.

Cheers,
Naomi [import]uid: 67217 topic_id: 30262 reply_id: 121294[/import]