Hello Guest

Author Topic: Best way to share attachpoints between sprites?  (Read 4280 times)

Vidd

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Best way to share attachpoints between sprites?
« on: February 27, 2014, 10:50:29 pm »
Say you have a character sprite with run, jump and attack animations. You specify attach points for all of these sprites.
Later in development you add a second player sprite with the same proportions. They're part of the same sprite collection and the animations for both characters are stored within the same collection.

What's the best way to apply the existing attachpoints? I tried simply playing the different animation but of course, the attachpoints are contained but they no longer animate.

I suppose I could create a ghost sprite that's invisible with the attachpoints I want and apply the actual animation as a child object. I assume there's a better way.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Best way to share attachpoints between sprites?
« Reply #1 on: February 28, 2014, 10:17:20 am »
The animations don't really matter, the attach points are created per instance. I'd just create all the attach points with the correct names irrespective of the characters they're attached to. Either that or I don't understand your question  - please explain in a bit more detail if so :)

Vidd

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Best way to share attachpoints between sprites?
« Reply #2 on: February 28, 2014, 10:26:16 am »
Sorry, my example might have confused matters as the animations don't really play into it. I understand that each sprite has it's own attach points.

My question is, if I have a lot of sprites with attach points, can I apply those somehow to another set of sprites? So if I had a Mario sprite with an attach point for his hat, I wouldn't need to redo the whole process for a set of Luigi sprites with the same dimensions but different images for example?

If that's not clear enough I'll be happy to upload a web demo of what I mean. Thanks for your time.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Best way to share attachpoints between sprites?
« Reply #3 on: February 28, 2014, 11:08:29 am »
Oh I see. It might be easier to transfer the data in the editor. Maybe write a simple editor script to do this. you will need to copy tk2dSpriteCollectionDefinition.attachPoints from the tk2dSpriteCollection objects.

Vidd

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Best way to share attachpoints between sprites?
« Reply #4 on: February 28, 2014, 06:21:22 pm »
Thanks, it's been a good while since I even looked at an Editor script but I'll definitely consider it. I was actually looking at the prefab within the 'data' folder to see if that data was easily accessible and it seems like something fun to try.

Thanks for the help.