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]