Hello Guest

Author Topic: Adding a sprite selector to my custom class  (Read 3034 times)

glimaleite

  • Newbie
  • *
  • Posts: 1
    • View Profile
Adding a sprite selector to my custom class
« on: January 17, 2014, 12:59:31 pm »
Hello there!

Its my first week using TK2d and I really like it. Now I am a bit stuck on this idea: I'd like to have sprite and collection selectors just like the ones we have when we have the class 2dtkSprite on a game object. I have a generic list of my custom class Slot, and I'd like to have those selectors for each slot that I add to this list.

I couldn't find any info on the forums, so thats why I posted.

Thanks.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Adding a sprite selector to my custom class
« Reply #1 on: January 18, 2014, 11:36:59 pm »
The line that draws the sprite selector is in tk2dSpriteEditor.cs
Code: [Select]
tk2dSpriteGuiUtility.SpriteSelector( targetSprites[0].Collection, targetSprites[0].spriteId, spriteChangedCallbackInstance, null );

You need a pair of tk2dSpriteCollectionData and int spriteId to define a sprite.

When a sprite is changed the callback is called you get the new sprite collection + id, and you just assign it to whatever. You get an additional data parameter (null above) which you can use to index into an array, store pointers, etc.