Hi robmiracle, thanks for your fast response, just getting back to this-
Unfortunatly that isn't working for me, though I'm probably just missing something simple. I get no errors, but the sprite never stops. I've confirmed that by removing the "if-then" from your "function RemoveExplosion", it does kill the sprite, so the issue is that "event.phase" never equals "end".
Anything I might have missed? Here is my code, just changed a few names:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| function RemoveExplosion(event)
--if event.phase == "end" then
event.target:removeSelf()
event.target = nil
--end
--return true
end
function NewEnemyExplosion(theEnemy)
local expInstance
expInstance = sprite.newSprite(expSet)
expInstance.x = theEnemy.x
expInstance.y = theEnemy.y
expInstance:addEventListener("sprite", RemoveExplosion)
expInstance:play()
end |
Ah, I see- my sprite never "ends", it only loops indefinitly. I changed it to "loop", and that works.
For the future (and now), where would I tell my sprite not to loop like this? I see a loop param in the "sprite.add" code, but not sure how do it with my setup:
1
2
3
4
| --|Creation and storing of basic sprite explosion
expSheet = sprite.newSpriteSheet( "explosionSprite_gradius.png", 96, 96 )
expSet = sprite.newSpriteSet(expSheet, 1, 4)
--| |
I didn't include my sprite init code:
1
2
3
| boomSpriteSheet = sprite.newSpriteSheet("exp2_alpha_1.png", 61, 61)
boomSpriteSet = sprite.newSpriteSet(boomSpriteSheet,1,16)
sprite.add(boomSpriteSet, "boom", 1, 16, 500, 1) |
views:1497 update:2011/10/9 22:34:50