Hello Guest

Author Topic: Changing Sprite Collection at Runtime  (Read 4892 times)

drkucho

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 72
  • Retro Arcade Freak
    • View Profile
    • Dr. Kucho!
Changing Sprite Collection at Runtime
« on: January 09, 2014, 04:14:46 pm »
I'm trying to do this, as per the script documentation.

tk2dBaseSprite.SetSprite   (tk2dSpriteCollectionData    newCollection, int    newSpriteId  )      

but i get Assets/Scripts/Player.js(384,56): BCE0005: Unknown identifier: 'KuchoShirtCollection'.

KuchoShirtCollection is the name of my sprite collection just like i have it on the project folder , yes i name my sprite collections ending on "collection" to avoid confusions

the question is how to get the tk2dSpriteCollectionData from code? javascript if possible, thanks

drkucho

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 72
  • Retro Arcade Freak
    • View Profile
    • Dr. Kucho!
Re: Changing Sprite Collection at Runtime
« Reply #1 on: January 10, 2014, 06:01:33 am »
Hello?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Changing Sprite Collection at Runtime
« Reply #2 on: January 10, 2014, 11:19:16 am »
As you can see in the script documentation you posted, you need a tk2dSpriteCollecitonData object as the first parameter. You can't just type the name of the object, you will need to load it somehow. One way to do that in Unity is using a public variable, i.e. create a public variable with the type and drag the collection into the slot in the inspector. Another way is to use Resources.Load (http://docs.unity3d.com/Documentation/ScriptReference/Resources.Load.html).

drkucho

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 72
  • Retro Arcade Freak
    • View Profile
    • Dr. Kucho!
Re: Changing Sprite Collection at Runtime
« Reply #3 on: January 10, 2014, 04:37:46 pm »
thanks a million , the drag and drop way is not very convenient for my case, ill check the load resources thing