I am planing to Write a Text adventure and I don't know how to make the text draw letter by letter in any other way than changing the variable from
h
to he
to hel
to hell
to hello
That would be a terrible amount of work since there are tons of dialogue.
Here is the source code so far
protected override void Update(GameTime gameTime)
{
//input code removed for clarity
if (Dialogue == 1)
{
Row1 = "Input Text 1 Here.";
Row2 = "Input Text 2 Here.";
Row3 = "Input Text 3 Here.";
Row4 = "Input Text 4 Here.";
}
if (Dialogue == 2)
{
Row1 = "Text 1";
Row2 = "Text 2";
Row3 = "Text 3";
Row4 = "Text 4";
}
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
spriteBatch.Draw(sampleBG, new Rectangle(0, 0, 800, 600), Color.White);
spriteBatch.Draw(TextBG, new Rectangle(0, 400, 800, 200), Color.White);
spriteBatch.DrawString(defaultfont, Row1, new Vector2(10, (textheight + (rowspace * 0))), Color.Black);
spriteBatch.DrawString(defaultfont, Row2, new Vector2(10, (textheight + (rowspace * 1))), Color.Black);
spriteBatch.DrawString(defaultfont, Row3, new Vector2(10, (textheight + (rowspace * 2))), Color.Black);
spriteBatch.DrawString(defaultfont, Row4, new Vector2(10, (textheight + (rowspace * 3))), Color.Black);
spriteBatch.End();
base.Draw(gameTime);
}