예제 #1
0
        // render animated text, moves according to m_angle
        protected void DrawWavingText(SpriteBatch batch,
            GameFont font, char[] letters, Color color)
        {
            // top left of text, if it were drawn just below
            // the vertical center of the screen
            int x = 32;
            int y = SCREEN_HEIGHT / 2;

            // vary the top location of each character
            int dy = 0;
            for (int i = 0; i < letters.Length; i++)
            {
                // simple sin function to produce a wave from -20.0f to +20.0f
                dy = (int)Math.Round(
                    Math.Sin(MathHelper.ToRadians(m_fAngle + (i * 10))) *
                    20.0f);
                // render each letter seperately
                x += (int)font.DrawString(batch,
                    letters[i], x, y + dy, color).X;
            }
        }