FadeOut Class Reference

Fades a screen towards a specific color. More...

#include <fadeout.hpp>

Inherits ScreenFade.

List of all members.

Public Member Functions

 FadeOut (float fade_time, Color dest_color=Color(0, 0, 0))
virtual ~FadeOut ()
virtual void update (float elapsed_time)
 gets called for once (per logical) frame.
virtual void draw (DrawingContext &context)
 gets called once per frame.
virtual bool done ()
 returns true if the effect is completed

Private Attributes

Color color
float fade_time
float accum_time


Detailed Description

Fades a screen towards a specific color.

Definition at line 26 of file fadeout.hpp.


Constructor & Destructor Documentation

FadeOut::FadeOut ( float  fade_time,
Color  dest_color = Color(0, 0, 0) 
)

Definition at line 21 of file fadeout.cpp.

00022   : color(color), fade_time(fade_time), accum_time(0)
00023 {
00024 }

FadeOut::~FadeOut (  )  [virtual]

Definition at line 26 of file fadeout.cpp.

00027 {
00028 }


Member Function Documentation

void FadeOut::update ( float  elapsed_time  )  [virtual]

gets called for once (per logical) frame.

ScreenFades should do their state updates and logic here

Implements ScreenFade.

Definition at line 31 of file fadeout.cpp.

References accum_time, and fade_time.

00032 {
00033   accum_time += elapsed_time;
00034   if(accum_time > fade_time)
00035     accum_time = fade_time;
00036 }

void FadeOut::draw ( DrawingContext context  )  [virtual]

gets called once per frame.

The ScreenFade should draw itself in this function. State changes should not be done in this function, but rather in update

Implements ScreenFade.

Definition at line 39 of file fadeout.cpp.

References accum_time, Color::alpha, color, DrawingContext::draw_filled_rect(), fade_time, LAYER_GUI, SCREEN_HEIGHT, and SCREEN_WIDTH.

00040 {
00041   Color col = color;
00042   col.alpha = accum_time / fade_time;
00043   context.draw_filled_rect(Vector(0, 0),
00044                            Vector(SCREEN_WIDTH, SCREEN_HEIGHT),
00045                            col, LAYER_GUI+1);
00046 }

bool FadeOut::done (  )  [virtual]

returns true if the effect is completed

Implements ScreenFade.

Definition at line 49 of file fadeout.cpp.

References accum_time, and fade_time.

00050 {
00051   return accum_time >= fade_time;
00052 }


Member Data Documentation

Color FadeOut::color [private]

Definition at line 39 of file fadeout.hpp.

Referenced by draw().

float FadeOut::fade_time [private]

Definition at line 40 of file fadeout.hpp.

Referenced by done(), draw(), and update().

float FadeOut::accum_time [private]

Definition at line 41 of file fadeout.hpp.

Referenced by done(), draw(), and update().


The documentation for this class was generated from the following files:
Generated on Mon Jun 9 03:38:30 2014 for SuperTux by  doxygen 1.5.1