tweener_group.cpp
Go to the documentation of this file.
/*
CLAW - a C++ Library Absolutely Wonderful
CLAW is a free library without any particular aim but being useful to
anyone.
Copyright (C) 2005-2011 Julien Jorge
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
contact: julien.jorge@gamned.org
*/
#include "claw/tween/tweener_group.hpp"
/*----------------------------------------------------------------------------*/
void claw::tween::tweener_group::insert( const tweener& t )
{
m_tweeners.push_back(t);
} // tweener_group::insert()
/*----------------------------------------------------------------------------*/
void claw::tween::tweener_group::clear()
{
m_tweeners.clear();
} // tweener_group::clear()
/*----------------------------------------------------------------------------*/
claw::tween::tweener_group* claw::tween::tweener_group::do_clone() const
{
return new tweener_group(*this);
} // tweener_group::do_clone()
/*----------------------------------------------------------------------------*/
bool claw::tween::tweener_group::do_is_finished() const
{
return m_tweeners.empty();
} // tweener_group::do_is_finished()
/*----------------------------------------------------------------------------*/
double claw::tween::tweener_group::do_update( double dt )
{
typedef std::list<tweener>::iterator iterator_type;
double result(dt);
iterator_type it = m_tweeners.begin();
while ( it != m_tweeners.end() )
{
const double r = it->update(dt);
result = std::min(result, r);
if ( it->is_finished() )
{
const iterator_type tmp(it);
++it;
m_tweeners.erase(tmp);
}
else
++it;
}
return result;
} // tweener_group::do_update()
/*----------------------------------------------------------------------------*/
bool claw::tween::tweener_group::empty() const
{
return m_tweeners.empty();
} // tweener_group::empty()
claw::tween::tweener_group
The tweener group manages several tweeners and remove them when they are over.
Definition: tweener_group.hpp:48
claw::tween::tweener_group::clear
void clear()
Remove all the tweeners from the group.
Definition: tweener_group.cpp:45
claw::tween::tweener_group::insert
void insert(const tweener &t)
Add a tweener in the group.
Definition: tweener_group.cpp:36
claw::tween::tweener_group::empty
bool empty() const
Tells if there is nothing in this group.
Definition: tweener_group.cpp:102
claw::tween::tweener
A tweener makes a value to evolve through time from a initial value to an end value according to a gi...
Definition: tweener.hpp:48
tweener_group.hpp
The tweener group manages several tweeners and remove them when they are over.