Bernice
Bernice

Reputation: 2592

How can I display animated text in C#

I have a connect four championship game. Is there a way in which I can display text in an animated way? What I mean is, after each round display Round 1 written on the screen.. after round 1 is over display ROUND 2.

What I mean is display text not in the form as a label but like in online games when they display text just appearing on the screen and disappearing after a few seconds.. don't know if it's possible!

Upvotes: 0

Views: 1891

Answers (2)

Mataniko
Mataniko

Reputation: 2242

You need to manually draw it on the form by getting the form Graphics object when the game is won.

Graphics g = this.CreateGraphics();
g.DrawString("Game Won!", DefaultFont, Brushes.Red, x,y);

Where this is the form in context and x,y are the coordinates to draw your text

of course as others have mentioned you'll have to do a timer that will change the x,y or other properties such as the font size every animation frame. You'll want to do that on a separate thread and double buffer the results

Upvotes: 2

Can Poyrazoğlu
Can Poyrazoğlu

Reputation: 34810

I don't know what you exactly mean by animation, but in general, you could create a timer that would 'animate' your text the way you want it to animate, like in every 20 millisecond or so. So for example, if you want to move your text simply from right to left, you would set myText.X += 5 or something alike, in your timer elapsed handler.

Upvotes: 0

Related Questions