I am currently messing up with the menu systems code I downloaded from MSD page.
It was built on XNA.
this is the code the makes it pulsate
public virtual void Draw(MenueScreen menuscScreen, bool isSelected, GameTime gameTime)
{
Color color = isSelected ? Color.Yellow : Color.White;
double time = gameTime.TotalGameTime.TotalSeconds;
float pulsate = (float) Math.Sin(time*2) + 1;
float scale = 1 + pulsate*0.05f*selectionFade;
ScreenManager screenManager = menuscScreen.ScreenManager;
SpriteBatch spriteBatch = screenManager.SpriteBatch;
SpriteFont font = screenManager.Font;
Vector2 origin = new Vector2(0,font.LineSpacing);
spriteBatch.DrawString(font,text,position,color,0,origin,scale,SpriteEffects.None, 0);
}
This is the math part i dont get on why did the author use,
float pulsate = (float) Math.Sin(time*2) + 1;
How did the programmer know if he is going to use Sin or Cos? I tried replacing it with cos still the same effects.
Sin and cos and tan will be on trigonometry part of math but where will you visualize it on screen? Even If i think that the screen is made up of many triangles or two triangles like this
or like this
I still dont know what triangle did the author use cause theres a lot of triangle that a rectangle is compose of.
and also for the effects i cant figure out what is the connection of using trigonometry on a text to make it smaller and bigger when selected. its really confusing.
Is that some random things that the original author use to confuse people instead of just putting a constant number?