CharacterCursor Class Reference

#include <cursor.h>

Collaboration diagram for CharacterCursor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void Reset ()
void Draw ()
void Refresh ()
void PointeObj (PhysicalObj *obj)
void FollowActiveCharacter ()
void Hide ()

Static Public Member Functions

static CharacterCursorGetInstance ()

Public Attributes

Spriteimage

Private Member Functions

 CharacterCursor ()
 ~CharacterCursor ()
bool IsDisplayed () const

Private Attributes

uint time_begin_anim
uint last_update
PhysicalObjobj_designe
int dy
bool actif
bool want_hide

Static Private Attributes

static CharacterCursorsingleton = NULL

Detailed Description

Definition at line 30 of file cursor.h.


Constructor & Destructor Documentation

CharacterCursor::CharacterCursor (  )  [private]

Definition at line 49 of file cursor.cpp.

00050 {
00051   actif = false;
00052   want_hide = false;
00053   time_begin_anim = 0;
00054   last_update = 0;
00055   image = NULL;
00056   dy = 0;  
00057 
00058   Profile *res = resource_manager.LoadXMLProfile( "graphism.xml", false);
00059   image = resource_manager.LoadSprite( res, "gfx/curseur");
00060   resource_manager.UnLoadXMLProfile( res);
00061 }

Here is the call graph for this function:

Here is the caller graph for this function:

CharacterCursor::~CharacterCursor (  )  [private]

Definition at line 63 of file cursor.cpp.

00064 {
00065   if(image) delete image;
00066 }


Member Function Documentation

void CharacterCursor::Draw (  ) 

Definition at line 69 of file cursor.cpp.

00070 {
00071   if (!IsDisplayed()) return;
00072   if (obj_designe == NULL) return;
00073   if (obj_designe -> IsGhost()) return;
00074 
00075   // Dessine le curseur autour du ver
00076   Point2i centre = obj_designe->GetCenter();
00077   uint x = centre.x - image->GetWidth()/2;
00078   uint y = obj_designe->GetY() - image->GetHeight() - y_min;
00079   
00080   image->Draw( Point2i(x, y+dy) );
00081 }

Here is the call graph for this function:

Here is the caller graph for this function:

void CharacterCursor::FollowActiveCharacter (  ) 

Definition at line 137 of file cursor.cpp.

00138 {
00139   PointeObj(&ActiveCharacter());
00140 }

Here is the call graph for this function:

Here is the caller graph for this function:

CharacterCursor * CharacterCursor::GetInstance (  )  [static]

Definition at line 42 of file cursor.cpp.

00042                                                {
00043   if (singleton == NULL) {
00044     singleton = new CharacterCursor();
00045   }
00046   return singleton;
00047 }

Here is the call graph for this function:

Here is the caller graph for this function:

void CharacterCursor::Hide (  ) 

Definition at line 124 of file cursor.cpp.

00125 {
00126   if(!actif) return;
00127   want_hide = true;
00128 }

Here is the caller graph for this function:

bool CharacterCursor::IsDisplayed (  )  const [private]

Definition at line 153 of file cursor.cpp.

00153                                         {
00154   return actif || (Time::GetInstance()->Read() < time_begin_anim + show_hide_time);
00155 }

Here is the call graph for this function:

Here is the caller graph for this function:

void CharacterCursor::PointeObj ( PhysicalObj obj  ) 

Definition at line 142 of file cursor.cpp.

00143 {
00144   if(actif && obj==obj_designe)
00145     return;
00146   obj_designe = obj;
00147   actif = true;
00148   want_hide = false;
00149   time_begin_anim = Time::GetInstance()->Read();
00150 }

Here is the call graph for this function:

Here is the caller graph for this function:

void CharacterCursor::Refresh (  ) 

Definition at line 83 of file cursor.cpp.

00084 {
00085   if (!IsDisplayed()) return;
00086 
00087   image->Scale(1.0, 1.0);
00088 
00089   Time * global_time = Time::GetInstance();
00090 
00091   //The arrow is appearing:
00092   if( actif && global_time->Read() < time_begin_anim + show_hide_time )
00093   {
00094     dy = (int)((camera.GetPosition().y - ActiveCharacter().GetY()) * (1.0 - (global_time->Read() - time_begin_anim) / (float)show_hide_time));
00095     return;
00096   }
00097 
00098   //If we want to hide the cursor, we have to wait the end of the current rebound to make the cursor disappear
00099   if(want_hide)
00100   {
00101     if( ((global_time->Read() - (time_begin_anim + show_hide_time)) % rebound_time < rebound_time / 2)
00102     &&  ((last_update                - (time_begin_anim + show_hide_time)) % rebound_time > rebound_time / 2))
00103     {
00104       //We are at the end of the rebound
00105       actif = false;
00106       time_begin_anim = global_time->Read();
00107     }
00108   }
00109 
00110   //The arrow is disappearing:
00111   if( !actif && global_time->Read() < time_begin_anim + show_hide_time )
00112   {
00113     dy = (int)((camera.GetPosition().y - ActiveCharacter().GetY()) * ((global_time->Read() - time_begin_anim) / (float)show_hide_time));
00114     return;
00115   }
00116 
00117   //The arrow is rebounding:
00118   Rebound(image, dy, time_begin_anim + show_hide_time, rebound_time, -y_max - (-y_min));
00119 
00120   last_update = global_time->Read();
00121 }

Here is the call graph for this function:

Here is the caller graph for this function:

void CharacterCursor::Reset (  ) 

Definition at line 130 of file cursor.cpp.

00131 {
00132   actif = false;
00133   want_hide = false;
00134   obj_designe = NULL;
00135 }

Here is the caller graph for this function:


Member Data Documentation

bool CharacterCursor::actif [private]

Definition at line 40 of file cursor.h.

int CharacterCursor::dy [private]

Definition at line 39 of file cursor.h.

Sprite* CharacterCursor::image

Definition at line 33 of file cursor.h.

uint CharacterCursor::last_update [private]

Definition at line 37 of file cursor.h.

PhysicalObj* CharacterCursor::obj_designe [private]

Definition at line 38 of file cursor.h.

CharacterCursor * CharacterCursor::singleton = NULL [static, private]

Definition at line 43 of file cursor.h.

uint CharacterCursor::time_begin_anim [private]

Definition at line 36 of file cursor.h.

bool CharacterCursor::want_hide [private]

Definition at line 41 of file cursor.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 13:41:30 2007 for Wormux by  doxygen 1.4.7