Problems using easing equations in C# XNA
        Posted  
        
            by 
                codinghands
            
        on Game Development
        
        See other posts from Game Development
        
            or by codinghands
        
        
        
        Published on 2012-04-05T19:39:46Z
        Indexed on 
            2012/04/05
            23:43 UTC
        
        
        Read the original article
        Hit count: 328
        
I'm having some trouble using the easing equations suggested by Robert Penner for ActionScript (http://www.robertpenner.com/easing/, and a Flash demo here) in my C# XNA game. Firstly, what is the definition of the following variables passed in as arguments to each equation?
float t, float b, float c, float d
I'm currently calculating the new X position of a sprite in the Update() loop, however even for the linear tween equation I'm getting some odd results. I'm using the following values:
float t = gameTime.TotalGameTime.TotalMilliseconds;
float d = 8000f;
float b = x.Position.X;
float c = (ScreenManager.Game.GraphicsDevice.Viewport.Width >> 1) - (x.Position.X + x.frameSize.X / 2);
And this equation for linear easing:
 float val = c*t/d + b;
© Game Development or respective owner