ShrinkFade Class Reference

Shrinks a rectangle screen towards a specific position. More...

#include <shrinkfade.hpp>

Inherits ScreenFade.

List of all members.

Public Member Functions

 ShrinkFade (const Vector &point, float fade_time)
virtual ~ShrinkFade ()
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

Vector dest
float fade_time
float accum_time
float speedleft
float speedright
float speedtop
float speedbottom


Detailed Description

Shrinks a rectangle screen towards a specific position.

Definition at line 26 of file shrinkfade.hpp.


Constructor & Destructor Documentation

ShrinkFade::ShrinkFade ( const Vector point,
float  fade_time 
)

Definition at line 21 of file shrinkfade.cpp.

References dest, SCREEN_HEIGHT, SCREEN_WIDTH, speedbottom, speedleft, speedright, speedtop, Vector::x, and Vector::y.

00021                                                           :
00022   dest(dest), 
00023   fade_time(fade_time), 
00024   accum_time(0),
00025   speedleft(),
00026   speedright(),
00027   speedtop(),
00028   speedbottom()
00029 {
00030   speedleft = dest.x / fade_time;
00031   speedright = (SCREEN_WIDTH - dest.x) / fade_time;
00032   speedtop = dest.y / fade_time;
00033   speedbottom = (SCREEN_HEIGHT - dest.y) / fade_time;
00034 }

ShrinkFade::~ShrinkFade (  )  [virtual]

Definition at line 36 of file shrinkfade.cpp.

00037 {
00038 }


Member Function Documentation

void ShrinkFade::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 41 of file shrinkfade.cpp.

References accum_time, and fade_time.

00042 {
00043   accum_time += elapsed_time;
00044   if(accum_time > fade_time)
00045     accum_time = fade_time;
00046 }

void ShrinkFade::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 49 of file shrinkfade.cpp.

References accum_time, dest, DrawingContext::draw_inverse_ellipse(), fade_time, LAYER_GUI, SCREEN_HEIGHT, and SCREEN_WIDTH.

00050 {
00051   float progress = accum_time / fade_time;
00052   context.draw_inverse_ellipse(dest,
00053                                Vector(2*SCREEN_WIDTH  * (1.0f - progress), 
00054                                       2*SCREEN_HEIGHT * (1.0f - progress)),
00055                                Color(0, 0, 0), LAYER_GUI+1);
00056 }

bool ShrinkFade::done (  )  [virtual]

returns true if the effect is completed

Implements ScreenFade.

Definition at line 59 of file shrinkfade.cpp.

References accum_time, and fade_time.

00060 {
00061   return accum_time >= fade_time;
00062 }


Member Data Documentation

Vector ShrinkFade::dest [private]

Definition at line 38 of file shrinkfade.hpp.

Referenced by draw(), and ShrinkFade().

float ShrinkFade::fade_time [private]

Definition at line 39 of file shrinkfade.hpp.

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

float ShrinkFade::accum_time [private]

Definition at line 40 of file shrinkfade.hpp.

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

float ShrinkFade::speedleft [private]

Definition at line 41 of file shrinkfade.hpp.

Referenced by ShrinkFade().

float ShrinkFade::speedright [private]

Definition at line 42 of file shrinkfade.hpp.

Referenced by ShrinkFade().

float ShrinkFade::speedtop [private]

Definition at line 43 of file shrinkfade.hpp.

Referenced by ShrinkFade().

float ShrinkFade::speedbottom [private]

Definition at line 44 of file shrinkfade.hpp.

Referenced by ShrinkFade().


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