Hello Guest

Author Topic: How To Implement A "Ribbon"?  (Read 3365 times)

viperld

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
How To Implement A "Ribbon"?
« on: December 01, 2013, 09:16:59 am »
Hello and please forgive me if this has been asked before (I personally wasn't able to find this question in previous posts).

I would like to implement a sprite/animation that exists between 2 Transforms.

For example, imagine 2 robotic orbs moving around a circular path, with a string of lightning between them. Like 2 balls attached by string, and the "ribbon" would be that string. The "ribbon" however has no slack and extends and shrinks as you pull the end Transforms farther apart or closer together.

 How would I implement this using 2D Toolkit?

I've tinkered with "ReshapeBounds" but my results have not been accurate so far.

Is there any other way to control the sprite's rectangle points that I'm not aware of?


unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: How To Implement A "Ribbon"?
« Reply #1 on: December 01, 2013, 12:35:50 pm »
If you set up the ribbon sprite with a specific length, it should be easy enough. Create your sprite with the pivot set to the left, then calculate the required sprite.scale for this - eg. scale.x = worldUnitDistanceToCover / sprite.CurrentSprite.GetUntrimmedBounds().size.x;

viperld

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: How To Implement A "Ribbon"?
« Reply #2 on: December 01, 2013, 10:17:32 pm »
Wow thanks for the speedy response   :)!

I'm going to go and try out what you've suggested.