Hello Guest

Author Topic: Adding Sprite Component  (Read 4501 times)

MrPriest

  • Newbie
  • *
  • Posts: 2
    • View Profile
Adding Sprite Component
« on: March 11, 2015, 07:19:43 am »
Hello.
I've been trying to add a sprite collection (don't remember the exact name, not near my project right now) via code.
I don't see any errors, but I also do not see anything being generated visually.

Basically I have a character game object, and the moves/stats/sprite are loaded when the player chooses the character they want to play as (fighter).
It works when I drag the game objects myself, but rather than have a game object for each character, I'd like to have one game object that can load any character data.

I do not have the code with me right now, but how would you accomplish it?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Adding Sprite Component
« Reply #1 on: March 11, 2015, 11:28:08 am »
You will need to AddComponent<tk2dSprite> and then call SetSprite to set the actual sprite to what you want. You'll need a reference to a tk2dSpriteCollectionData.

MrPriest

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Adding Sprite Component
« Reply #2 on: March 11, 2015, 12:04:08 pm »
I believe that this is what I have done.
I'll get home (at work currently) and verify.
Either way, thanks for replying!