I'm trying to animate my object according to a set of recorded values from kinect skeleton stream by saving the (x,y,z) stream from the skeletal data into a list and then set my objects x and y position from the x,y of the list. However, once the list end has been reached it starts to animate again from the start. I don't want that - I just want the model position to keep going in the positive X direction. Is there any way I can check if end of the list has been reached and to just update the model position in x direction?

Or is there any other way to continue moving my sprite once the points in the list are over... i dont want it to start animating all the way again..

   protected override void Update(GameTime gameTime)

            //position += spriteSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds;

            //// TODO: Add your update logic here
            using (StreamReader r = new StreamReader(f))
                string line;
                Viewport view = graphics.GraphicsDevice.Viewport;
                int maxWidth = view.Width;
                int maxHeight = view.Height;

                while((line = r.ReadLine()) != null)

                    string[] temp = line.Split(',');

                    int x = (int) Math.Floor(((float.Parse(temp[0]) * 0.5f) + 0.5f) * maxWidth);
                    int y = (int) Math.Floor(((float.Parse(temp[1]) * -0.5f) + 0.5f) * maxHeight);

                    motion_2.Add(new Point(x, y));  


                position.X = motion_2[i].X;
                position.Y = motion_2[i].Y;





  • 1
    \$\begingroup\$ What is 'f' which you are using as a parameter to your StreamReader? Is there any length parameter for 'f', if not, could you check the length in advance? \$\endgroup\$
    – AturSams
    Oct 5, 2012 at 15:24
  • \$\begingroup\$ f is just storing a string file path . . for the stream reader to read from . . \$\endgroup\$ Oct 5, 2012 at 15:29

1 Answer 1


Problem solved. . . I have used int count; instead of i in the above code

        if (++count >= motion_2.Count)

            if (position.X < -200)
                count = 0;

            float x = (float)((motion_2[count].X * 0.5f) + 0.5f) * maxX);
            float y = (float)(((motion_2[count].Y * -0.5f) + 0.5f) * maxY);

            position.X = x;
            position.Y = y;
            scale = (float)motion_2[count].Z;


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .