Setting a sprite's sequence dynamically

Hi,

I am creating a newSprite in the scene:create function with a default sequence. I would like the users to be able to go to a different scene and define their own sequence then return to the original scene to view that sequence.

Since the new sequence is user defined I can’t add it at the start. I tried to create the sprite in the scene:show function but that keeps the old sprite in the background.

Is there a way to add a new sequence to an existing sprite. If not, is there a way to delete the old sprite so that it doesn’t show when I return to the scene?

I did a quick search in the forum but I couldn’t find  similar question (possibly I was searching with the wrong keywords).

Thanks.

Have you tried a google search instead? Forum search engines are generally only trumped by Bing in terms of uselessness.

I don’t think that there is a way to add new sequences to an existing sprite. As for destroying (or removing) sprites, you simply do the same thing as with any display object.

I would probably complete this by simply creating a table for all possible sprites and a subtable for each sprite that contains their sequence data. Then, whenever a new sequence was added to a sprite, it’s simply a new entry in the table’s subtable. Once that’s done, I’d destroy the display object and recreate it using the updated sequence data in the table.

@XeduR @Spyric

Thanks. Removing the object worked  :slight_smile:

Putting all the possible sequences from the start is not practical since the sprite had 28 different frames and the user can select any subset of those frames.

Yeah, but that’s what the table is for. I am not suggesting that you create a single sequence file and use that, but instead create a table where all of the sequences that you will or may need are placed.

If the user creates a new sequence, store it in the table. Ten new sequences? Table. If you have sequences that are specific to some sprite, use a subtable.

Then, when new sequences have been added to the table, if you need, you can remove the existing sprite object and then simply use the table (or one of its subtables) for the sequence data when you create new sprites.

 

Have you tried a google search instead? Forum search engines are generally only trumped by Bing in terms of uselessness.

I don’t think that there is a way to add new sequences to an existing sprite. As for destroying (or removing) sprites, you simply do the same thing as with any display object.

I would probably complete this by simply creating a table for all possible sprites and a subtable for each sprite that contains their sequence data. Then, whenever a new sequence was added to a sprite, it’s simply a new entry in the table’s subtable. Once that’s done, I’d destroy the display object and recreate it using the updated sequence data in the table.

@XeduR @Spyric

Thanks. Removing the object worked  :slight_smile:

Putting all the possible sequences from the start is not practical since the sprite had 28 different frames and the user can select any subset of those frames.

Yeah, but that’s what the table is for. I am not suggesting that you create a single sequence file and use that, but instead create a table where all of the sequences that you will or may need are placed.

If the user creates a new sequence, store it in the table. Ten new sequences? Table. If you have sequences that are specific to some sprite, use a subtable.

Then, when new sequences have been added to the table, if you need, you can remove the existing sprite object and then simply use the table (or one of its subtables) for the sequence data when you create new sprites.