# NewGamePhysics.GraphicalElements.ScrollingText Class Reference

Implements a left-to-right scrolling text scroller which displays as band across the whole width of the screen. More...

List of all members.

## Public Member Functions
| ScrollingText (string text, SpriteFont font, int screenWidth, int yPos)
void | Update (GameTime gameTime)
| Update the scroller state.
void | Draw (GameTime gameTime, SpriteBatch spriteBatch)
| Draw the scroller.
## Properties
string | Text`[get, set]`
| Gets or sets the current text of the scroller. If text is set, the scroller offset resets.
float | ScrollerSpeed`[get, set]`
| Gets or sets the current scroller speed in pixel per second. Default is 100 pixel/sec.
Color | TextColor`[get, set]`
| Gets or sets the current text color. Default is White.
float | TextScale`[get, set]`
| Gets or sets the current text scale. Default is 1.0.

## Detailed Description

Implements a left-to-right scrolling text scroller which displays as band across the whole width of the screen.

Definition at line 13 of file ScrollingText.cs.

## Constructor & Destructor Documentation

NewGamePhysics.GraphicalElements.ScrollingText.ScrollingText | ( | string | text,
|  | SpriteFont | font,
|  | int | screenWidth,
|  | int | yPos |
| ) |  |  |

Parameters:

  | text | The text to scroll.
  | font | The font to use for the text.
  | screenWidth | The width of the screen.
  | yPos | The vertical position for the scroller.

Definition at line 71 of file ScrollingText.cs.

    00072         {
    00073
    00074             this.text = text;
    00075             this.textFont = font;
    00076             this.textSize = this.textFont.MeasureString(text);
    00077
    00078             this.textColor = Color.White;
    00079             this.textScale = 1.0f;
    00080
    00081             // Set x from screen, y from position
    00082             this.screenWidth = screenWidth;
    00083             this.scrollerOffset = new Vector2(this.screenWidth, yPos);
    00084             this.scrollerSpeed = 100.0f;
    00085         }

## Member Function Documentation

void NewGamePhysics.GraphicalElements.ScrollingText.Draw | ( | GameTime | gameTime,
|  | SpriteBatch | spriteBatch |
| ) |  |  |

Draw the scroller.

Parameters:

  | gameTime | Current game time.
  | spriteBatch | The sprite batch to use for drawing.

Definition at line 161 of file ScrollingText.cs.

    00162         {
    00163             spriteBatch.Begin();
    00164             spriteBatch.DrawString(
    00165                 this.textFont,
    00166                 this.text,
    00167                 this.scrollerOffset,
    00168                 this.textColor,
    00169                 0,
    00170                 textOrigin,
    00171                 this.textScale,
    00172                 SpriteEffects.None,
    00173                 0);
    00174             spriteBatch.End();
    00175         }

void NewGamePhysics.GraphicalElements.ScrollingText.Update | ( | GameTime | gameTime | ) |

Update the scroller state.

Definition at line 134 of file ScrollingText.cs.

    00135         {
    00136             // Move scroller
    00137             scrollerOffset.X -= scrollerSpeed * (float)gameTime.ElapsedGameTime.Milliseconds * 0.001f;
    00138
    00139             // Wrap motion
    00140             if (scrollerSpeed > 0.0f)
    00141             {
    00142                 if ((this.scrollerOffset.X + this.textSize.X) < 0)
    00143                 {
    00144                     scrollerOffset.X = this.screenWidth;
    00145                 }
    00146             }
    00147             else
    00148             {
    00149                 if (this.scrollerOffset.X > this.screenWidth)
    00150                 {
    00151                     scrollerOffset.X = -this.textSize.X;
    00152                 }
    00153             }
    00154         }

## Property Documentation

float NewGamePhysics.GraphicalElements.ScrollingText.ScrollerSpeed`[get, set]`

Gets or sets the current scroller speed in pixel per second. Default is 100 pixel/sec.

Definition at line 106 of file ScrollingText.cs.

string NewGamePhysics.GraphicalElements.ScrollingText.Text`[get, set]`

Gets or sets the current text of the scroller. If text is set, the scroller offset resets.

Definition at line 92 of file ScrollingText.cs.

Color NewGamePhysics.GraphicalElements.ScrollingText.TextColor`[get, set]`

Gets or sets the current text color. Default is White.

Definition at line 116 of file ScrollingText.cs.

float NewGamePhysics.GraphicalElements.ScrollingText.TextScale`[get, set]`

Gets or sets the current text scale. Default is 1.0.

Definition at line 126 of file ScrollingText.cs.

The documentation for this class was generated from the following file:

- C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/NewGamePhysics/GraphicalElements/ScrollingText.cs