Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Setting a sprite's sequence dynamically
Started by ammar71 Feb 23 2019 11:22 AM

4 replies to this topic

Best Answer XeduR @Spyric , 23 February 2019 - 01:31 PM

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.

[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

ammar71

[GLOBAL: userInfoPane.html]
ammar71
  • Observer

  • 23 posts
  • Corona SDK

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.



[TOPIC: post.html]
#2

nick_sherman

[GLOBAL: userInfoPane.html]
nick_sherman
  • Corona Geek

  • 1,761 posts
  • Corona SDK

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

[TOPIC: post.html]
#3

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 687 posts
  • Corona SDK

  Best Answer

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.


  • ammar71 likes this

[TOPIC: post.html]
#4

ammar71

[GLOBAL: userInfoPane.html]
ammar71
  • Observer

  • 23 posts
  • Corona SDK

@XeduR @Spyric

 

Thanks. Removing the object worked  :)

 

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.



[TOPIC: post.html]
#5

XeduR @Spyric

[GLOBAL: userInfoPane.html]
XeduR @Spyric
  • Contributor

  • 687 posts
  • Corona SDK

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.


 




[topic_controls]
[/topic_controls]