Well, i want to shoot lazers. All works fine but but i cant get to remove the lazers from the screen after they’ve been shot.
Lazers are sprite instances. I only want to remove the one which has reached its destination, not the full sprite sheet using dispose()!. My code can explain the rest. I’d really much appreciate if i can get help. Thanx in advance.
local sprite = require “sprite”
local button = display.newImage (“fire.png”) --shoot lazers button
button.x = 250
button.y = 250
local blastersheet = sprite.newSpriteSheet(“blaster.png”, 64, 25)
local blasterset = sprite.newSpriteSet (blastersheet, 1, 11)
sprite.add (blasterset, “fireA”, 1, 11, 600, 3)
local remover = function (obj)
si:dispose()
blastersheet = sprite.newSpriteSheet(“blaster.png”, 64, 25)
blasterset = sprite.newSpriteSet (blastersheet, 1, 11)
sprite.add (blasterset, “fireA”, 1, 11, 600, 3)
end
local function down ()
local si = sprite.newSprite (blasterset)
si.x = 20
si.y = 20
si:prepare(“fireA”)
si:play(“fireA”)
transition.to(si,{delay = 1, time = 2000, x = si.x + 250, onComplete = remover})
end
button:addEventListener(“touch”, down)
[import]uid: 176335 topic_id: 32240 reply_id: 332240[/import]