•      Sign In
• Create Account

Need scary sound effects or creepy audio loops for your next horror-themed game? Check out Highscore Vol.3 - The Horror Edition in our marketplace. 50 sounds and 10 loops for only \$9.99!

### #ActualArthur Souza

Posted 16 September 2012 - 03:51 AM

Well, you are using the total elapsed amount of game time in seconds to determine which frame is going to be drawn. I would use a timer to wait before going to the next frame, it would go something like this

// members
expFrameID = 0;
timer = 0;
UpdateAnimation()
{
// ElapsedGametime gets how long has it been since the last update
timer += (int) GameTimer.ElapsedGameTime.TotalMilisseconds;
if(timer >= 60) // Because you want 16 frames persecond at least, correct? So 60ms I guess.
{
timer = 0;
if(expFrameID == 15)
expFrameID  = 0;
else
expFrameID++;
}

Rectangle expRect = new Rectangle(expFrameID * expFrameWidth, 0, 63, 63);
if (expFrameID == 15)
{
expIsDrawn = true;
}
}
Draw()
{
spriteBatch.Draw(explosion, shipLocation, expRect, Color.White, 0f, new Vector2(32, 32), 1.0f, pickupSpriteEffects, 0.1f);
}


### #2Arthur Souza

Posted 16 September 2012 - 03:51 AM

Well, you are using the total elapsed amount of game time in seconds to determine which frame is going to be drawn. I would use a timer to wait before going to the next frame, it would go something like this

// members
expFrameID = 0;
timer = 0;
UpdateAnimation()
{
// ElapsedGametime gets how long has it been since the last update
timer += (int) GameTimer.ElapsedGameTime.TotalMilisseconds;
if(timer >= 60) // Because you want 16 frames persecond at least, correct? So 60ms I guess.
{
timer = 0;
if(expFrameID == 15)
expFrameID  = 0;
else
expFrameID++;
}

Rectangle expRect = new Rectangle(expFrameID * expFrameWidth, 0, 63, 63);
if (expFrameID == 15)
{
expIsDrawn = true;
}
}
Draw()
{
spriteBatch.Draw(explosion, shipLocation, expRect, Color.White, 0f, new Vector2(32, 32), 1.0f, pickupSpriteEffects, 0.1f);
}


### #1Arthur Souza

Posted 16 September 2012 - 03:49 AM

Well, you are using the total elapsed amount of game time in seconds to determine which frame is going to be drawn. I would use a timer to wait before going to the next frame, it would go something like this

// members
expFrameID = 0;
timer = 0;

UpdateAnimation()
{
// ElapsedGametime gets how long has it been since the last update
timer += (int) GameTimer.ElapsedGameTime.TotalMilisseconds;
if(timer >= 60) // Because you want 16 frames persecond at least, correct? So 60ms I guess.
{
timer = 0;
if(expFrameID == 15)
expFrameID  = 0;
else
expFrameID++;

}
Rectangle expRect = new Rectangle(expFrameID * expFrameWidth, 0, 63, 63);

if (expFrameID == 15)
{
expIsDrawn = true;

}
}

Draw()
{
spriteBatch.Draw(explosion, shipLocation, expRect, Color.White, 0f, new Vector2(32, 32), 1.0f, pickupSpriteEffects, 0.1f);
}

}


PARTNERS