Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/animation_player.cc @ 3812

Last change on this file since 3812 was 3812, checked in by bensch, 19 years ago

orxonox/trunk: animation-player added

File size: 2.3 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_ANIM
17
18#include "animation_player.h"
19
20using namespace std;
21
22
23/**
24   \brief standard constructor
25*/
26AnimationPlayer::AnimationPlayer () 
27{
28   this->setClassName ("AnimationPlayer");
29
30   this->animationList = new tList<Anim>();
31}
32
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}
47
48/**
49   \brief standard deconstructor
50
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.
54*/
55AnimationPlayer::~AnimationPlayer () 
56{
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;
69}
70
71/**
72   \brief adds an Animation to the AnimationList.
73   \param animation the Animation to handle
74
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();
78*/
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 TracBrowser for help on using the repository browser.