2D Toolkit Forum

2D Toolkit => Support => Topic started by: viperld on December 01, 2013, 09:16:59 am

Title: How To Implement A "Ribbon"?
Post by: viperld 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?

Title: Re: How To Implement A "Ribbon"?
Post by: unikronsoftware 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;
Title: Re: How To Implement A "Ribbon"?
Post by: viperld 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.