Implements a left-to-right scrolling text scroller which displays as band across the whole width of the screen. More...
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. | |
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.
| NewGamePhysics.GraphicalElements.ScrollingText.ScrollingText | ( | string | text, | |
| SpriteFont | font, | |||
| int | screenWidth, | |||
| int | yPos | |||
| ) |
| 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 }
| void NewGamePhysics.GraphicalElements.ScrollingText.Draw | ( | GameTime | gameTime, | |
| SpriteBatch | spriteBatch | |||
| ) |
Draw the scroller.
| gameTime | Current game time. | |
| spriteBatch | The sprite batch to use for drawing. |
Definition at line 161 of file ScrollingText.cs.
| 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 }
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.
1.6.2