Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Adjust fading speed to current frame rate

$
0
0

@LEM wrote:

Hi all,

In my game, when the user is browsing through the menus I show a fade in effect every time a menu is displayed.
I use the alpha value that goes from 0 to 255. I would like the duration going from 0 to 255 to be the same no matter the current frame rate is.

This is what I'm doing but it's not working properly.

int AlphaValue = 0;
public void Update(GameTime gameTime)
{
   float time = (float)gameTime.ElapsedGameTime.TotalSeconds;

   AlphaValueIncrement = 10;

   AlphaValue += AlphaValueIncrement;
   AlphaValue = (int)(AlphaValue  / time);
}

Any ideas what could be wrong?

Thanks.

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles