2D Toolkit Forum

2D Toolkit => Support => Topic started by: monoclesociety on June 13, 2014, 11:10:53 pm

Title: Dynamically creating an animation from an array of custom sprites
Post by: monoclesociety on June 13, 2014, 11:10:53 pm
I have an array of 12 sprites that I create with a with tk2dSprite.CreateFromTexture. I would like to be able to dynamically create a tk2dAnimation and add them these sprite to it. I've seen some code before that uses a tk2dSpriteCollectionData, but not sure if that would apply.

Thoughts?
Title: Re: Dynamically creating an animation from an array of custom sprites
Post by: unikronsoftware on June 13, 2014, 11:27:30 pm
each tk2dSprite you create in that manner will have a collection associated with it. You can get to it by using sprite.Collection
Title: Re: Dynamically creating an animation from an array of custom sprites
Post by: monoclesociety on June 13, 2014, 11:29:16 pm
So then for each tk2dSpriteAnimationFrame I would have to associate the collection? I'll look at the previous example, and come back with sample code for a solution so that way anybody else will be able that needs it will have it :-D
Title: Re: Dynamically creating an animation from an array of custom sprites
Post by: monoclesociety on June 13, 2014, 11:31:36 pm
each tk2dSprite you create in that manner will have a collection associated with it. You can get to it by using sprite.Collection

I'm assuming this is the code that would get me started:

http://2dtoolkit.com/forum/index.php/topic,3671.msg17641.html#msg17641
Title: Re: Dynamically creating an animation from an array of custom sprites
Post by: unikronsoftware on June 13, 2014, 11:32:15 pm
Yes, thats pretty much it. You will need to assign the correct sprite collection and spriteId per frame.