Sprite is disappearing when spriteInstance:play() ends.

I have a spritesheet of 45 frames, and I use the following code code to manage that:

[lua]

local objectSheet = sprite.newSpriteSheet(“objectsheet.png”, 64, 64);
local objectSet = sprite.newSpriteSet(objectSheet, 1, 45);
sprite.add(objectSet, “doit”, 1, 26, 2000, 1);
sprite.add(objectSet, “dothat”, 27, 45, 1500, 1);
local object = sprite.newSprite(objectSet);
object.x, object.y = 50,50;

local controller = false;

local function spriteController(e)
if(e.phase == “ended”)then
if(controller == false)then
object:prepare(“doit”);
object:play();
controller = true;
elseif(e.phase == “ended” and controller == true)then
object:prepare(“dothat”);
object:play();
controller = false;
end
end
end

object:addEventListener(“touch”, spriteController);
[/lua]

The problem I have is that when I touch the sprite, the sprite sequence “doit” plays good, but when I touch it again the sprite sequence “dothat” plays but ends with no image; it disappears at the end of the sequence.

What’s wrong, guys?
Thanks.

[import]uid: 162818 topic_id: 35810 reply_id: 335810[/import]

Hi @wiler_carmo,
I just want to mention that you’re using the deprecated sprite library and methods. I suggest that you convert to the current library/methods, since the old one will receive no support or added functionality at this point.

Here’s a quick tutorial on the current method:
http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

Best regards,
Brent Sorrentino [import]uid: 200026 topic_id: 35810 reply_id: 142437[/import]

Hi @wiler_carmo,
I just want to mention that you’re using the deprecated sprite library and methods. I suggest that you convert to the current library/methods, since the old one will receive no support or added functionality at this point.

Here’s a quick tutorial on the current method:
http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/

Best regards,
Brent Sorrentino [import]uid: 200026 topic_id: 35810 reply_id: 142437[/import]