Search code examples
c#xnatweeneasing

How to use one of this classes for tweens in custom framework (xna like)


I am trying to implement this tween class for my custom game framework, I don't exactly know how to use it.

(The framework is pretty similar to XNA).

This tinyTween class seems very complete, but I cannot quite understand it.

https://gist.github.com/liaoguipeng13/717f83f4971230e70d7e

http://theinstructionlimit.com/flash-style-tweeneasing-functions-in-c

Should I instantiate the tweening class? or can I use it without instantiating it?.

Also for moving sprites I can set in the update my functions SetVelocityX, SetX, SetAccelX etc...

I am interested in making a sprite move from point (100,150) to (400,600) with a nice moving effect...


Solution

  • Should I instantiate the tweening class?

    According to the Tween class, yes, you need to instantiate the class. Though as you can tell by all the classes that inherits from it, you can most likely use one of those for whatever you're planning on using it for, instead of making your own implementations.

    I am interested in making a sprite move from point (100,150) to (400,600) with a nice moving effect...

    Based on the Tween class, it seems very simple. All you gotta do is call Start with the start and end position, a duration, and a formula for movement. The Tween class should handle the rest, so long as you remember to call Update every frame.