Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3812 in orxonox.OLD for orxonox/trunk/src/animation_player.cc


Ignore:
Timestamp:
Apr 13, 2005, 11:08:43 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: animation-player added

File:
1 copied

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/animation_player.cc

    r3807 r3812  
    1 
    2 
    31/*
    42   orxonox - the future of 3D-vertical-scrollers
     
    1210
    1311   ### File Specific:
    14    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1513   co-programmer: ...
    1614*/
    1715
    18 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ANIM
    1917
    20 #include "proto_class.h"
    21 
    22 #include "stdincl.h" // maybe
     18#include "animation_player.h"
    2319
    2420using namespace std;
     
    2723/**
    2824   \brief standard constructor
    29    \todo this constructor is not jet implemented - do it
    3025*/
    31 ProtoClass::ProtoClass ()
     26AnimationPlayer::AnimationPlayer ()
    3227{
    33    this->setClassName ("ProtoClass");
     28   this->setClassName ("AnimationPlayer");
     29
     30   this->animationList = new tList<Anim>();
    3431}
    3532
     33/**
     34   \brief the singleton reference to this class
     35*/
     36AnimationPlayer* AnimationPlayer::singletonRef = NULL;
     37
     38/**
     39   \returns a Pointer to this Class
     40*/
     41AnimationPlayer* AnimationPlayer::getInstance(void)
     42{
     43  if (!AnimationPlayer::singletonRef)
     44    AnimationPlayer::singletonRef = new AnimationPlayer();
     45  return AnimationPlayer::singletonRef;
     46}
    3647
    3748/**
    3849   \brief standard deconstructor
    3950
     51   !! DANGER !! when unloading the AnimationPlayer no other Function
     52   should reference any Animations, because it automatically deletes
     53   them. This usually happens when unloading a World.
    4054*/
    41 ProtoClass::~ProtoClass ()
     55AnimationPlayer::~AnimationPlayer ()
    4256{
    43   // delete what has to be deleted here
     57  // deleting the Animation List AND all the elements of the List
     58   tIterator<Anim>* animIt = animationList->getIterator();
     59  Anim* anim = animIt->nextElement();
     60  while( anim != NULL)
     61    {
     62      delete anim;
     63      anim = animIt->nextElement();
     64    }
     65  delete animIt;
     66  delete this->animationList;
     67
     68  AnimationPlayer::singletonRef = NULL;
    4469}
    4570
    4671/**
    47    \brief nonsense - delete this method
    48    \param realy nothing to give
    49    \returns true or false - probably nothing?
     72   \brief adds an Animation to the AnimationList.
     73   \param animation the Animation to handle
    5074
    51    this is just to show the doxygen abilities (this for example is an extension for a long comment)
     75   when adding a Animation the Animation will too be deleted when
     76   the AnimationPlayer gets deleted. Consider not adding it, or
     77   unadding it with animation->notHandled();
    5278*/
    53 bool ProtoClass::doNonSense (int nothing) {}
     79void AnimationPlayer::addAnimation(Anim* animation)
     80{
     81  this->animationList->add(animation);
     82}
     83
     84/**
     85   \brief Ticks all the animations in animationList
     86   \param timePassed the time passed since the last tick.
     87*/
     88void AnimationPlayer::tick(float timePassed)
     89{
     90  tIterator<Anim>* animIt = animationList->getIterator();
     91  Anim* anim = animIt->nextElement();
     92  while( anim != NULL)
     93    {
     94      anim->tick(timePassed);
     95      anim = animIt->nextElement();
     96    }
     97  delete animIt;
     98
     99}
Note: See TracChangeset for help on using the changeset viewer.