Problem with spriteInstance:Prepare e SpriteMultiSets

I was refactoring part of my code to use MultiSet sprites and had figured out this problem, when using prepare to use a named sequence which maps to a set that uses the second sprite. A sample code:

[lua] local ssheet1 = sprite.newSpriteSheet(“sheet1.png”, 52, 52);
local ssheet2 = sprite.newSpriteSheet(“sheet2.png”, 52, 52);

local sset = sprite.newSpriteMultiSet({
{sheet = ssheet1, frames = {1, 2, 3}},
{sheet = ssheet2, frames = {1, 2, 3}}});

sprite.add(sset, “red”, 1, 3, 1000, 1);
sprite.add(sset, “black”, 4, 3, 1000, 1);

local spt = sprite.newSprite(sset);
spt.x, spt.y = display.contentWidth * .5, display.contentHeight * .5;
spt:prepare(“black”);
spt:play();[/lua]
In spite of preparing the “black” set, the first frame shown is allways from “red”.

Sheets: http://dl.dropbox.com/u/28948129/sheet1.png and http://dl.dropbox.com/u/28948129/sheet2.png.

Please, could you confirm this?
Thank you. [import]uid: 50425 topic_id: 16649 reply_id: 316649[/import]

In this case, I could “solve” the problem changing lines 11 to 14 this way:
[lua] local spt = sprite.newSprite(sset);
spt.x, spt.y = display.contentWidth * .5, display.contentHeight * .5;
spt.currentFrame = 4;
spt:prepare(“black”);
spt:play();[/lua]

But… after calling spt:prepare() once, I could not change the currentFrame anymore, and the problem remains (prepare “black” and a “red” frame is shown). =/

See bellow:
[lua] local spt = sprite.newSprite(sset);
spt.x, spt.y = display.contentWidth * .5, display.contentHeight * .5;
spt:prepare(“red”);
spt:play();

timer.performWithDelay(2000, function()
spt.currentFrame = 4;
spt:prepare(“black”);
spt:play();
end);[/lua] [import]uid: 50425 topic_id: 16649 reply_id: 62737[/import]

could you solve this issue?? [import]uid: 90610 topic_id: 16649 reply_id: 64604[/import]

Hi there!
No, I could not.

The multiset page had an atualization last week, with a remark that I think that could solve this problem, but I could not test it yet. Maybe you would like to take a look (in “remark” section): http://developer.anscamobile.com/reference/index/spritenewspritemultiset

Please, If you solve the problem with this remark, could you post back here? [import]uid: 50425 topic_id: 16649 reply_id: 64605[/import]

hi there!

I’ve tried everything, also the delayed change of the animation. It does not seem to work. The single sheets seem to work, but i cant switch inbetween them. I’ll work on it, i let you know if i can figure out something.

I’ve changed all my movieclip animations to spritesheets… tesxture memory is much lower, but i cant get the animations running without playing a wrong frame first or at the end. very odd behavior. [import]uid: 90610 topic_id: 16649 reply_id: 64610[/import]

Yeah, I understand.
As I could not figured this out, I’ve changed all my code to work with single sheets. It is a lot more (and complicated) work, but I could not afford to wait any longer. =(

I think that because of that workaround, this will not be fixed any time soon. [import]uid: 50425 topic_id: 16649 reply_id: 64632[/import]

I guess i got to do that too. The pretty thing about multiset has been that i could add a listener once to the char. now switching with different sheets, it seems that i need to add the eventlistener again and again… unless my code is the reason for that :slight_smile: [import]uid: 90610 topic_id: 16649 reply_id: 64634[/import]

Yes, I guess that you will have to.
Or could you use a biggger spritesheet (combine the too spritesheets in one image file). Could you do that?

In my game, I could not, so I did it with diferente sheets. And I didn’t have listeners also. [import]uid: 50425 topic_id: 16649 reply_id: 64642[/import]

i have 10 diff sprite sheets… so its no option.

wish me good luck :slight_smile: [import]uid: 90610 topic_id: 16649 reply_id: 64643[/import]