Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualThe King2

Posted 16 March 2013 - 12:43 PM

The problem most likely lies here:

this.Increment = this.Opacity / totalTime;

You are calculating the increment step over and over again, while the opacity is acutally decreasing. So naturally Increment gets smaller and smaller until it hits 0.0f. Calculate Increment only once when starting the fade OR store the opacity when starting the fade OR use a constant instead of this.Opacity (if you want to fade the game screen it will probably always be 1.0f/255?).

 

Actually, I'd advice you to split this method in two - StartFade and UpdateFade. StartFade would get the fadeTime as a paramter, while UpdateFade would get gameTime as a parameter, and perform the actual fade. You will get precisier results if you, instead of calculating Increment and subing from this.Opacity, like that:

 

this.Opacity = this.OpacityBeforeFade - (this.OpacityBeforeFade) * (this.FadeTime / this.PassedTime);

#3The King2

Posted 16 March 2013 - 12:42 PM

The problem most likely lies here:

this.Increment = this.Opacity / totalTime;

You are calculating the increment step over and over again, while the opacity is acutally decreasing. So naturally Increment gets smaller and smaller until it hits 0.0f. Calculate Increment only once when starting the fade OR store the opacity when starting the fade OR use a constant instead of this.Opacity (if you want to fade the game screen it will probably always be 1.0f/255?).

 

Actually, I'd advice you to split this method in two - StartFade and UpdateFade. StartFade would get the fadeTime as a paramter, while UpdateFade would get gameTime as a parameter, and perform the actual fade. You will get precisier results if you, instead of calculating Increment and subing from this.Opacity, say

 

this.Opacity = this.OpacityBeforeFade - (this.OpacityBeforeFade) * (this.FadeTime / this.PassedTime);


#2The King2

Posted 16 March 2013 - 12:35 PM

The problem most likely lies here:

this.Increment = this.Opacity / totalTime;

You are calculating the increment step over and over again, while the opacity is acutally decreasing. So naturally Increment gets smaller and smaller until it hits 0.0f. Calculate Increment only once when starting the fade OR store the opacity when starting the fade OR use a constant instead of this.Opacity (if you want to fade the game screen it will probably always be 1.0f/255?).


#1The King2

Posted 16 March 2013 - 12:33 PM

The problem most likely lies here:

this.Opacity / totalTime;

You are calculating the increment step over and over again, while the opacity is acutally decreasing. So naturally Increment gets smaller and smaller until it hits 0.0f. Calculate Increment only once when starting the fade.


PARTNERS