# How to determine the end of list has been reached?

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;

{
string line;
Viewport view = graphics.GraphicsDevice.Viewport;
int maxWidth = view.Width;
int maxHeight = view.Height;

{

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);

}

}

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

i++;

a_butterfly_up.Update(gameTime);

a_butterfly_side.Update(gameTime);

G_vidPlayer.Play(mossV);

base.Update(gameTime);
}

• 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? – wolfdawn Oct 5 '12 at 15:24
• f is just storing a string file path . . for the stream reader to read from . . – Sweta Dwivedi Oct 5 '12 at 15:29

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

        if (++count >= motion_2.Count)
{
position.X--;

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

else
{
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;

}