Hello Guest

Author Topic: Dynamically creating an animation from an array of custom sprites  (Read 4115 times)

monoclesociety

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Dynamically creating an animation from an array of custom sprites
« Reply #1 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

monoclesociety

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Dynamically creating an animation from an array of custom sprites
« Reply #2 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

monoclesociety

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Dynamically creating an animation from an array of custom sprites
« Reply #3 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

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Dynamically creating an animation from an array of custom sprites
« Reply #4 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.