From 3303defc5ffddcc86f0553662d9a715149a37209 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 24 Dec 2017 03:50:43 -0300 Subject: [PATCH] Refactorized Interpolation1d and Interpolation2d. --HG-- branch : dev --- include/eepp/math/interpolation1d.hpp | 60 ++++++----- include/eepp/math/interpolation2d.hpp | 55 ++++++---- include/eepp/ui/uicontrolanim.hpp | 28 ++++-- src/eepp/math/interpolation1d.cpp | 137 +++++++++++++++---------- src/eepp/math/interpolation2d.cpp | 140 +++++++++++++++++--------- src/eepp/ui/uicontrolanim.cpp | 76 +++++++------- src/examples/sprites/sprites.cpp | 14 +-- src/test/eetest.cpp | 16 +-- 8 files changed, 316 insertions(+), 210 deletions(-) diff --git a/include/eepp/math/interpolation1d.hpp b/include/eepp/math/interpolation1d.hpp index 06b89e0d8..a9a094b98 100644 --- a/include/eepp/math/interpolation1d.hpp +++ b/include/eepp/math/interpolation1d.hpp @@ -14,9 +14,9 @@ template class tPoint1d { public: tPoint1d() { p = 0; t = 0.f; } - tPoint1d( const T& Pos, const Float& Time ) { p = Pos; t = Time; } + tPoint1d( const T& pos, const Time& time ) { p = pos; t = time; } T p; - Float t; + Time t; }; typedef tPoint1d Point1d; @@ -27,57 +27,60 @@ class EE_API Interpolation1d { ~Interpolation1d(); - typedef cb::Callback0 OnPathEndCallback; + typedef cb::Callback1 OnPathEndCallback; - typedef cb::Callback0 OnStepCallback; + typedef cb::Callback1 OnStepCallback; /** Add a new point */ - void addWaypoint( const Float Pos, const Float Time = 0 ); + Interpolation1d& add( const Float& pos, const Time& Time = Time::Zero ); /** Edit a point */ - bool editWaypoint( const unsigned int& PointNum, const Float& NewPos, const Float NewTime = 0 ); + Interpolation1d& edit( const unsigned int& PointNum, const Float& pos, const Time& time = Time::Zero ); /** Erase a point */ - bool eraseWaypoint( const unsigned int& PointNum ); + Interpolation1d& erase( const unsigned int& PointNum ); + + /** Same as add( pos, time ).add( pos ); */ + Interpolation1d& wait( const Float& pos, const Time& time ); + + /** Same as add( pos, waitTime ).add( pos, addTime ); */ + Interpolation1d& waitAndAdd( const Float& pos, const Time& waitTime, const Time& addTime ); /** Start the animation */ - void start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() ); + Interpolation1d& start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() ); /** Stop the animation */ - void stop(); + Interpolation1d& stop(); /** Sets a path end callback */ - void setPathEndCallback( OnPathEndCallback PathEndCallback ); + Interpolation1d& setPathEndCallback( OnPathEndCallback PathEndCallback ); /** Sets a step callback */ - void setStepCallback( OnStepCallback StepCallback ); + Interpolation1d& setStepCallback( OnStepCallback StepCallback ); /** Update the movement interpolation */ void update( const Time& Elapsed ); /** Reset the class */ - void reset(); + Interpolation1d& reset(); /** @return The Current Position */ - const Float& getPos(); - - /** @return The Current Real Position */ - const Float& getRealPos() const; + const Float& getPosition(); /** @return If movement interpolation is a loop */ const bool& getLoop() const; /** Set if loop the movement interpolation */ - void setLoop( const bool& loop ); + Interpolation1d& setLoop( const bool& loop ); /** Clear all the points */ - void clearWaypoints(); + Interpolation1d& clear(); /** @return If the animation ended */ const bool& ended() const; /** Set the current interpolation speed */ - void setSpeed( const Float speed ); + Interpolation1d& setSpeed( const Float speed ); /** Get the current interpolation speed */ const Float& getSpeed() const; @@ -85,10 +88,10 @@ class EE_API Interpolation1d { /** @return If enabled */ const bool& isEnabled() const; - void setEnabled( const bool& enabled ); + Interpolation1d& setEnabled( const bool& enabled ); - /** Instead if setting the time between every waypoing, this set a total time for all the movement interpolation. */ - void setTotalTime( const Time& TotTime ); + /** Instead if setting the time between each waypoint, this set a total time for all the movement interpolation. */ + Interpolation1d& setTotalTime( const Time& TotTime ); /** @return the vector of points */ const std::vector& getPoints() const; @@ -100,17 +103,22 @@ class EE_API Interpolation1d { Point1d* getCurrentNext() const; /** @return The Current Position in the vector */ - const unsigned int& getCurrentPos() const; + const unsigned int& getCurrentPositionIndex() const; /** @return The path end position */ - const Float& getEndPos(); + const Float& getFinalPosition(); /** Set the type of interpolation to be used */ - void setType( Ease::Interpolation InterpolationType ); + Interpolation1d& setType( Ease::Interpolation InterpolationType ); /** @return The type of the interpolation */ const int& getType() const; + + UintPtr getData() const; + + void setData(const UintPtr & data); protected: + UintPtr mData; int mType; bool mEnable; bool mUpdate; @@ -120,7 +128,7 @@ class EE_API Interpolation1d { Float mTotDist; Float mCurPos; unsigned int mCurPoint; - double mCurTime; + Time mCurTime; Float mSpeed; diff --git a/include/eepp/math/interpolation2d.hpp b/include/eepp/math/interpolation2d.hpp index 68dff59c4..5db45b49e 100755 --- a/include/eepp/math/interpolation2d.hpp +++ b/include/eepp/math/interpolation2d.hpp @@ -15,9 +15,9 @@ template class tPoint2d { public: tPoint2d() { p = Vector2(0,0); t = 0; } - tPoint2d( const Vector2& Pos, const Float& Time ) { p = Pos; t = Time; } + tPoint2d( const Vector2& pos, const Time& time ) { p = pos; t = time; } Vector2 p; - Float t; + Time t; }; typedef tPoint2d Point2d; @@ -28,57 +28,63 @@ class EE_API Interpolation2d { ~Interpolation2d(); - typedef cb::Callback0 OnPathEndCallback; + typedef cb::Callback1 OnPathEndCallback; - typedef cb::Callback0 OnStepCallback; + typedef cb::Callback1 OnStepCallback; /** Add a new waypoint */ - void addWaypoint( const Vector2f& Pos, const Float& Time = 0.f ); + Interpolation2d& add(const Vector2f& pos, const Time& time = Time::Zero ); /** Edit a waypoint */ - bool editWaypoint( const unsigned int& PointNum, const Vector2f& NewPos, const Float& NewTime ); + Interpolation2d& edit( const unsigned int& PointNum, const Vector2f& pos, const Time& time ); /** Erase a waypoint */ - bool eraseWaypoint( const unsigned int& PointNum ); + Interpolation2d& erase( const unsigned int& PointNum ); + + /** Same as add( pos, time ).add( pos ); */ + Interpolation2d& wait( const Vector2f & pos, const Time& time ); + + /** Same as add( pos, waitTime ).add( pos, addTime ); */ + Interpolation2d& waitAndAdd( const Vector2f& pos, const Time& waitTime, const Time& addTime ); /** Start the animation ( will reset the current state, and start from the beginning ) * @param PathEndCallback An optional callback fired when the animation ends. * @param StepCallback An optional callback that is fired every time that a step is completed. */ - void start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() ); + Interpolation2d& start( OnPathEndCallback PathEndCallback = OnPathEndCallback(), OnStepCallback StepCallback = OnStepCallback() ); /** Stop the animation ( Enable = false ) */ - void stop(); + Interpolation2d& stop(); /** Sets a path end callback */ - void setPathEndCallback( OnPathEndCallback PathEndCallback ); + Interpolation2d& setPathEndCallback( OnPathEndCallback PathEndCallback ); /** Sets a step callback */ - void setStepCallback( OnStepCallback StepCallback ); + Interpolation2d& setStepCallback( OnStepCallback StepCallback ); /** Update the movement interpolation */ void update( const Time& Elapsed ); /** Reset the class */ - void reset(); + Interpolation2d& reset(); /** @return The Current Position */ - const Vector2f& getPos(); + const Vector2f& getPosition(); /** @return If movement interpolation is a loop */ bool getLoop() const; /** Set if loop the movement interpolation */ - void setLoop( const bool& loop ); + Interpolation2d& setLoop( const bool& loop ); /** Clear all the waypoints */ - void clearWaypoints(); + Interpolation2d& clear(); /** @return If the animation ended */ bool ended() const; /** Instead if setting the time between every waypoing, this set a total time for all the movement interpolation. */ - void setTotalTime( const Time & TotTime ); + Interpolation2d& setTotalTime( const Time & TotTime ); /** @return The Current Node */ Point2d * getCurrentActual() const; @@ -87,13 +93,13 @@ class EE_API Interpolation2d { Point2d * getCurrentNext() const; /** @return The Current Position in the vector */ - const Uint32& getCurrentPos() const; + const Uint32& getCurrentPositionIndex() const; /** @return the vector of waypoints */ - const std::vector& getWaypoints() const; + const std::vector& getPoints() const; /** Set the current interpolation speed ( This will destroy the time of the interpolation and create one depending on the speed ) ( pixels per second ) */ - void setSpeed( const Float& speed ); + Interpolation2d& setSpeed( const Float& speed ); /** Get the current interpolation speed */ const Float& getSpeed() const; @@ -102,14 +108,19 @@ class EE_API Interpolation2d { const bool& isEnabled() const; /** Set it enabled or not */ - void setEnabled( const bool& enabled ); + Interpolation2d& setEnabled( const bool& enabled ); /** Set the type of interpolation to be used */ - void setType( Ease::Interpolation InterpolationType ); + Interpolation2d& setType( Ease::Interpolation InterpolationType ); /** @return The type of the interpolation */ const int& getType() const; + + UintPtr getData() const; + + void setData(const UintPtr & data); protected: + UintPtr mData; int mType; bool mEnable; bool mUpdate; @@ -119,7 +130,7 @@ class EE_API Interpolation2d { Float mTotDist; Vector2f mCurPos; Uint32 mCurPoint; - double mCurTime; + Time mCurTime; Float mSpeed; Point2d* mActP; diff --git a/include/eepp/ui/uicontrolanim.hpp b/include/eepp/ui/uicontrolanim.hpp index 8695b3649..1f573e860 100644 --- a/include/eepp/ui/uicontrolanim.hpp +++ b/include/eepp/ui/uicontrolanim.hpp @@ -55,23 +55,33 @@ class EE_API UIControlAnim : public UIDragableControl { bool isAnimating(); - Interpolation1d * startAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& alphaChilds = true, const Ease::Interpolation& getType = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + Interpolation1d * startAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - Interpolation2d * startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& getType = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + Interpolation2d * startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - Interpolation2d * startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& getType = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + Interpolation2d * startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - Interpolation2d * startTranslation( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& getType = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + Interpolation2d * startTranslation( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - Interpolation1d * startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& getType = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + Interpolation1d * startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - Interpolation1d * createFadeIn( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& getType = Ease::Linear ); + Interpolation1d * startAlphaAnim( const Float& To, const Time& TotalTime, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - Interpolation1d * createFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& getType = Ease::Linear ); + Interpolation2d * startScaleAnim( const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - Interpolation1d * closeFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& getType = Ease::Linear ); + Interpolation2d * startScaleAnim( const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - Interpolation1d * disableFadeOut( const Time & Time, const bool& alphaChilds = true, const Ease::Interpolation& getType = Ease::Linear ); + Interpolation2d * startTranslation( const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); + + Interpolation1d * startRotation( const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + + Interpolation1d * createFadeIn( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); + + Interpolation1d * createFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); + + Interpolation1d * closeFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); + + Interpolation1d * disableFadeOut( const Time & Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); Interpolation1d * getRotationInterpolation(); diff --git a/src/eepp/math/interpolation1d.cpp b/src/eepp/math/interpolation1d.cpp index 3bcee4393..fd664f809 100644 --- a/src/eepp/math/interpolation1d.cpp +++ b/src/eepp/math/interpolation1d.cpp @@ -5,6 +5,7 @@ using namespace EE::Math::easing; namespace EE { namespace Math { Interpolation1d::Interpolation1d() : + mData(0), mType(Ease::Linear), mEnable(false), mUpdate(true), @@ -13,7 +14,7 @@ Interpolation1d::Interpolation1d() : mTotDist(0.f), mCurPos(0.f), mCurPoint(0), - mCurTime(0), + mCurTime(Time::Zero), mSpeed(1.3f), mActP(NULL), mNexP(NULL), @@ -25,7 +26,7 @@ Interpolation1d::Interpolation1d() : Interpolation1d::~Interpolation1d() { } -void Interpolation1d::start( OnPathEndCallback PathEndCallback, OnStepCallback StepCallback) { +Interpolation1d& Interpolation1d::start( OnPathEndCallback PathEndCallback, OnStepCallback StepCallback) { mEnable = true; mOnPathEndCallback = PathEndCallback; mOnStepCallback = StepCallback; @@ -40,119 +41,137 @@ void Interpolation1d::start( OnPathEndCallback PathEndCallback, OnStepCallback S } else { mEnable = false; } + + return *this; } -void Interpolation1d::stop() { +Interpolation1d& Interpolation1d::stop() { mEnable = false; + return *this; } -void Interpolation1d::setPathEndCallback( OnPathEndCallback PathEndCallback ) { +Interpolation1d& Interpolation1d::setPathEndCallback( OnPathEndCallback PathEndCallback ) { mOnPathEndCallback = PathEndCallback; + return *this; } -void Interpolation1d::setStepCallback( OnStepCallback StepCallback ) { +Interpolation1d& Interpolation1d::setStepCallback( OnStepCallback StepCallback ) { mOnStepCallback = StepCallback; + return *this; } -void Interpolation1d::reset() { +Interpolation1d &Interpolation1d::wait( const Float& pos, const Time& time ) { + add( pos, time ).add( pos ); + return *this; +} + +Interpolation1d &Interpolation1d::waitAndAdd(const EE::Float & pos, const EE::System::Time & waitTime, const EE::System::Time & addTime) { + add( pos, waitTime ).add( pos, addTime ); +} + +Interpolation1d & Interpolation1d::reset() { + mData = 0; mTotDist = 0.f; mActP = mNexP = NULL; mEnable = false; mCurPoint = 0; mUpdate = true; mEnded = false; - mCurTime = 0; + mCurTime = Time::Zero; mOnPathEndCallback = NULL; + mOnStepCallback = NULL; if ( mPoints.size() ) mCurPos = mPoints[0].p; + + return *this; } -void Interpolation1d::clearWaypoints() { +Interpolation1d& Interpolation1d::clear() { reset(); mPoints.clear(); + return *this; } -void Interpolation1d::addWaypoint( const Float Pos, const Float Time ) { - mPoints.push_back( Point1d( Pos, Time ) ); +Interpolation1d & Interpolation1d::add( const Float & pos, const Time& time ) { + mPoints.push_back( Point1d( pos, time ) ); if ( mPoints.size() >= 2 ) mTotDist += eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[ mPoints.size() - 2 ].p ); + + return *this; } -bool Interpolation1d::editWaypoint( const unsigned int& PointNum, const Float& NewPos, const Float NewTime ) { +Interpolation1d& Interpolation1d::edit( const unsigned int& PointNum, const Float& pos, const Time& time ) { if ( PointNum < mPoints.size() ) { - if ( 0 == PointNum ) + if ( 0 == PointNum ) { mTotDist -= eeabs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); - else + } else { mTotDist -= eeabs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); + } - mPoints[ PointNum ] = Point1d( NewPos, NewTime ); + mPoints[ PointNum ] = Point1d( pos, time ); if ( 0 == PointNum ) { - if ( PointNum + 1 < mPoints.size() ) + if ( PointNum + 1 < mPoints.size() ) { mTotDist += eeabs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); - } - else + } + } else { mTotDist += eeabs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); - - return true; + } } - return false; + + return *this; } -bool Interpolation1d::eraseWaypoint( const unsigned int& PointNum ) { +Interpolation1d& Interpolation1d::erase( const unsigned int& PointNum ) { if ( PointNum < mPoints.size() && !mEnable ) { - if ( 0 == PointNum ) + if ( 0 == PointNum ) { mTotDist -= eeabs( mPoints[ PointNum ].p - mPoints[ PointNum + 1 ].p ); - else + } else { mTotDist -= eeabs( mPoints[ PointNum ].p - mPoints[ PointNum - 1 ].p ); + } mPoints.erase( mPoints.begin() + PointNum ); - - return true; } - return false; + + return *this; } -const Float& Interpolation1d::getEndPos() { +const Float& Interpolation1d::getFinalPosition() { return mPoints[ mPoints.size() - 1 ].p; } -const Float& Interpolation1d::getPos() { - return mCurPos; -} - -const Float& Interpolation1d::getRealPos() const { +const Float& Interpolation1d::getPosition() { return mCurPos; } void Interpolation1d::update( const Time& Elapsed ) { if ( mEnable && mPoints.size() > 1 && mCurPoint != mPoints.size() ) { if ( mUpdate ) { - mCurTime = 0; + mCurTime = Time::Zero; mActP = &mPoints[ mCurPoint ]; if ( mCurPoint + 1 < mPoints.size() ) { mNexP = &mPoints[ mCurPoint + 1 ]; if ( mOnStepCallback.IsSet() ) - mOnStepCallback(); + mOnStepCallback(*this); } else { if ( mOnStepCallback.IsSet() ) - mOnStepCallback(); + mOnStepCallback(*this); if ( mLoop ) { mNexP = &mPoints[ 0 ]; if ( mOnPathEndCallback.IsSet() ) - mOnPathEndCallback(); + mOnPathEndCallback(*this); } else { mEnable = false; mEnded = true; if ( mOnPathEndCallback.IsSet() ) { - mOnPathEndCallback(); + mOnPathEndCallback(*this); if ( !mEnable ) mOnPathEndCallback.Reset(); @@ -160,12 +179,13 @@ void Interpolation1d::update( const Time& Elapsed ) { return; } } + mUpdate = false; } - mCurTime += Elapsed.asMilliseconds(); + mCurTime += Elapsed; - mCurPos = easingCb[ mType ]( mCurTime, mActP->p, ( mNexP->p - mActP->p ), mActP->t ); + mCurPos = easingCb[ mType ]( mCurTime.asMilliseconds(), mActP->p, ( mNexP->p - mActP->p ), mActP->t.asMilliseconds() ); if ( mCurTime >= mActP->t ) { mCurPos = mNexP->p; @@ -180,26 +200,28 @@ void Interpolation1d::update( const Time& Elapsed ) { } } -void Interpolation1d::setTotalTime( const Time & TotTime ) { +Interpolation1d& Interpolation1d::setTotalTime( const Time & TotTime ) { Float tdist = mTotDist; if ( tdist == 0.0f ) { mPoints.clear(); - return; + return *this; } if ( mLoop ) { tdist += eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ); - mPoints[ mPoints.size() - 1 ].t = eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ) * TotTime.asMilliseconds() / tdist; + mPoints[ mPoints.size() - 1 ].t = Milliseconds( eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ) * TotTime.asMilliseconds() / tdist ); } for ( unsigned int i = 0; i < mPoints.size() - 1; i++) { Float CurDist = eeabs( mPoints[i].p - mPoints[i + 1].p ); - mPoints[i].t = CurDist * TotTime.asMilliseconds() / tdist; + mPoints[i].t = Milliseconds( CurDist * TotTime.asMilliseconds() / tdist ); } + + return *this; } -void Interpolation1d::setSpeed( const Float Speed ) { +Interpolation1d& Interpolation1d::setSpeed( const Float Speed ) { Float tdist = mTotDist; mSpeed = Speed; Float CurDist; @@ -207,7 +229,7 @@ void Interpolation1d::setSpeed( const Float Speed ) { if ( mPoints.size() ) { if ( tdist == 0.0f ) { mPoints.clear(); - return; + return *this; } Float TotTime = tdist * ( 1000.f / mSpeed ); @@ -216,31 +238,43 @@ void Interpolation1d::setSpeed( const Float Speed ) { CurDist = eeabs( mPoints[ mPoints.size() - 1 ].p - mPoints[0].p ); tdist += CurDist; - mPoints[ mPoints.size() - 1 ].t = CurDist * TotTime / tdist; + mPoints[ mPoints.size() - 1 ].t = Milliseconds( CurDist * TotTime / tdist ); TotTime = tdist * ( 1000.f / mSpeed ); } for ( unsigned int i = 0; i < mPoints.size() - 1; i++) { CurDist = eeabs( mPoints[i].p - mPoints[i + 1].p ); - mPoints[i].t = CurDist * TotTime / tdist; + mPoints[i].t = Milliseconds( CurDist * TotTime / tdist ); } } + + return *this; } -void Interpolation1d::setType( Ease::Interpolation InterpolationType ) { +Interpolation1d& Interpolation1d::setType( Ease::Interpolation InterpolationType ) { mType = InterpolationType; + return *this; } const int& Interpolation1d::getType() const { return mType; } +UintPtr Interpolation1d::getData() const { + return mData; +} + +void Interpolation1d::setData(const UintPtr & data) { + mData = data; +} + const bool& Interpolation1d::getLoop() const { return mLoop; } -void Interpolation1d::setLoop( const bool& loop ) { +Interpolation1d& Interpolation1d::setLoop( const bool& loop ) { mLoop = loop; + return *this; } const bool& Interpolation1d::ended() const { @@ -255,7 +289,7 @@ Point1d * Interpolation1d::getCurrentNext() const { return mNexP; } -const Uint32& Interpolation1d::getCurrentPos() const { +const Uint32& Interpolation1d::getCurrentPositionIndex() const { return mCurPoint; } @@ -271,8 +305,9 @@ const bool& Interpolation1d::isEnabled() const { return mEnable; } -void Interpolation1d::setEnabled( const bool& Enabled ) { +Interpolation1d& Interpolation1d::setEnabled( const bool& Enabled ) { mEnable = Enabled; + return *this; } }} diff --git a/src/eepp/math/interpolation2d.cpp b/src/eepp/math/interpolation2d.cpp index 130f8a948..a70c42c28 100755 --- a/src/eepp/math/interpolation2d.cpp +++ b/src/eepp/math/interpolation2d.cpp @@ -5,6 +5,7 @@ using namespace EE::Math::easing; namespace EE { namespace Math { Interpolation2d::Interpolation2d() : + mData(0), mType(Ease::Linear), mEnable(false), mUpdate(true), @@ -12,7 +13,7 @@ Interpolation2d::Interpolation2d() : mEnded(false), mTotDist(0.f), mCurPoint(0), - mCurTime(0.0f), + mCurTime(Time::Zero), mSpeed(1.3f), mOnPathEndCallback(NULL), mOnStepCallback(NULL) @@ -22,7 +23,7 @@ Interpolation2d::Interpolation2d() : Interpolation2d::~Interpolation2d() { } -void Interpolation2d::start( OnPathEndCallback PathEndCallback, OnStepCallback StepCallback ) { +Interpolation2d& Interpolation2d::start( OnPathEndCallback PathEndCallback, OnStepCallback StepCallback ) { mEnable = true; mOnPathEndCallback = PathEndCallback; mOnStepCallback = StepCallback; @@ -37,81 +38,105 @@ void Interpolation2d::start( OnPathEndCallback PathEndCallback, OnStepCallback S } else { mEnable = false; } + + return *this; } -void Interpolation2d::stop() { +Interpolation2d& Interpolation2d::stop() { mEnable = false; + return *this; } -void Interpolation2d::setPathEndCallback( OnPathEndCallback PathEndCallback ) { +Interpolation2d& Interpolation2d::setPathEndCallback( OnPathEndCallback PathEndCallback ) { mOnPathEndCallback = PathEndCallback; + return *this; } -void Interpolation2d::setStepCallback( OnStepCallback StepCallback ) { +Interpolation2d& Interpolation2d::setStepCallback( OnStepCallback StepCallback ) { mOnStepCallback = StepCallback; + return *this; } -void Interpolation2d::reset() { +Interpolation2d& Interpolation2d::reset() { + mData = 0; mTotDist = 0.f; mEnable = false; mCurPoint = 0; - mCurTime = 0; + mCurTime = Time::Zero; mUpdate = true; mEnded = false; + mOnPathEndCallback = NULL; + mOnStepCallback = NULL; if ( mPoints.size() ) mCurPos = mPoints[0].p; + + return *this; } -void Interpolation2d::clearWaypoints() { +Interpolation2d& Interpolation2d::clear() { reset(); mPoints.clear(); + + return *this; } -void Interpolation2d::addWaypoint( const Vector2f& Pos, const Float& Time ) { - mPoints.push_back( Point2d(Pos, Time) ); +Interpolation2d& Interpolation2d::add( const Vector2f& pos, const Time& time ) { + mPoints.push_back( Point2d( pos, time ) ); - if ( mPoints.size() >= 2 ) - { + if ( mPoints.size() >= 2 ) { mTotDist += mPoints[ mPoints.size() - 1 ].p.distance( mPoints[ mPoints.size() - 2 ].p ); } + + return *this; } -bool Interpolation2d::editWaypoint( const unsigned int& PointNum, const Vector2f& NewPos, const Float& NewTime ) { +Interpolation2d& Interpolation2d::edit(const unsigned int& PointNum, const Vector2f& pos, const Time& time ) { if ( PointNum < mPoints.size() ) { - if ( 0 == PointNum ) + if ( 0 == PointNum ) { mTotDist -= mPoints[ PointNum ].p.distance( mPoints[ PointNum + 1 ].p ); - else + } else { mTotDist -= mPoints[ PointNum ].p.distance( mPoints[ PointNum - 1 ].p ); + } - mPoints[ PointNum ] = Point2d( NewPos, NewTime ); + mPoints[ PointNum ] = Point2d( pos, time ); if ( 0 == PointNum ) { if ( PointNum + (unsigned int)1 < mPoints.size() ) mTotDist += mPoints[ PointNum ].p.distance( mPoints[ PointNum + 1 ].p ); - } else + } else { mTotDist += mPoints[ PointNum ].p.distance( mPoints[ PointNum - 1 ].p ); - - return true; + } } - return false; + + return *this; } -bool Interpolation2d::eraseWaypoint( const unsigned int& PointNum ) { +Interpolation2d& Interpolation2d::erase( const unsigned int& PointNum ) { if ( PointNum < mPoints.size() && !mEnable ) { - if ( 0 == PointNum ) + if ( 0 == PointNum ) { mTotDist -= mPoints[ PointNum ].p.distance( mPoints[ PointNum + 1 ].p ); - else + } else { mTotDist -= mPoints[ PointNum ].p.distance( mPoints[ PointNum - 1 ].p ); + } mPoints.erase( mPoints.begin() + PointNum ); - - return true; } - return false; + + return *this; } -void Interpolation2d::setSpeed( const Float& Speed ) { +Interpolation2d &Interpolation2d::wait( const Vector2f& pos, const Time& time ) { + add( pos, time ).add( pos ); + return *this; +} + +Interpolation2d &Interpolation2d::waitAndAdd( const Vector2f& pos, const Time& waitTime, const Time& addTime ) { + add( pos, waitTime ).add( pos, addTime ); + return *this; +} + +Interpolation2d& Interpolation2d::setSpeed( const Float& Speed ) { Float tdist = mTotDist; mSpeed = Speed; Float CurDist; @@ -119,7 +144,7 @@ void Interpolation2d::setSpeed( const Float& Speed ) { if ( mPoints.size() ) { if ( tdist == 0.0f ) { mPoints.clear(); - return; + return *this; } Float TotTime = tdist * ( 1000.f / mSpeed ); @@ -128,47 +153,49 @@ void Interpolation2d::setSpeed( const Float& Speed ) { CurDist = mPoints[ mPoints.size() - 1 ].p.distance( mPoints[0].p ); tdist += CurDist; - mPoints[ mPoints.size() - 1 ].t = CurDist * TotTime / tdist; + mPoints[ mPoints.size() - 1 ].t = Milliseconds( CurDist * TotTime / tdist ); TotTime = tdist * ( 1000.f / mSpeed ); } for ( unsigned int i = 0; i < mPoints.size() - 1; i++) { CurDist = mPoints[i].p.distance( mPoints[i + 1].p ); - mPoints[i].t = CurDist * TotTime / tdist; + mPoints[i].t = Milliseconds( CurDist * TotTime / tdist ); } } + + return *this; } -const Vector2f& Interpolation2d::getPos() { +const Vector2f& Interpolation2d::getPosition() { return mCurPos; } void Interpolation2d::update( const Time& Elapsed ) { if ( mEnable && mPoints.size() > 1 && mCurPoint != mPoints.size() ) { if ( mUpdate ) { - mCurTime = 0; + mCurTime = Time::Zero; mActP = &mPoints[ mCurPoint ]; if ( mCurPoint + 1 < mPoints.size() ) { mNexP = &mPoints[ mCurPoint + 1 ]; if ( mOnStepCallback.IsSet() ) - mOnStepCallback(); + mOnStepCallback(*this); } else { if ( mOnStepCallback.IsSet() ) - mOnStepCallback(); + mOnStepCallback(*this); if ( mLoop ) { mNexP = &mPoints[ 0 ]; if ( mOnPathEndCallback.IsSet() ) - mOnPathEndCallback(); + mOnPathEndCallback(*this); } else { mEnable = false; mEnded = true; if ( mOnPathEndCallback.IsSet() ) { - mOnPathEndCallback(); + mOnPathEndCallback(*this); if ( !mEnable ) mOnPathEndCallback.Reset(); @@ -179,10 +206,10 @@ void Interpolation2d::update( const Time& Elapsed ) { mUpdate = false; } - mCurTime += Elapsed.asMilliseconds(); + mCurTime += Elapsed; - mCurPos.x = easingCb[ mType ]( mCurTime, mActP->p.x, ( mNexP->p.x - mActP->p.x ), mActP->t ); - mCurPos.y = easingCb[ mType ]( mCurTime, mActP->p.y, ( mNexP->p.y - mActP->p.y ), mActP->t ); + mCurPos.x = easingCb[ mType ]( mCurTime.asMilliseconds(), mActP->p.x, ( mNexP->p.x - mActP->p.x ), mActP->t.asMilliseconds() ); + mCurPos.y = easingCb[ mType ]( mCurTime.asMilliseconds(), mActP->p.y, ( mNexP->p.y - mActP->p.y ), mActP->t.asMilliseconds() ); if ( mCurTime >= mActP->t ) { mCurPos = mNexP->p; @@ -197,41 +224,55 @@ void Interpolation2d::update( const Time& Elapsed ) { } } -void Interpolation2d::setTotalTime( const Time& TotTime ) { +Interpolation2d& Interpolation2d::setTotalTime( const Time& TotTime ) { unsigned int i; Float tdist = mTotDist; if ( !mPoints.size() ) - return; + return *this; if ( tdist == 0.0f ) { mPoints.clear(); - return; + return *this; } if ( mLoop ) { tdist += mPoints[ mPoints.size() - 1 ].p.distance( mPoints[0].p ); - mPoints[ mPoints.size() - 1 ].t = mPoints[ mPoints.size() - 1 ].p.distance( mPoints[0].p ) * TotTime.asMilliseconds() / tdist; + mPoints[ mPoints.size() - 1 ].t = Milliseconds( mPoints[ mPoints.size() - 1 ].p.distance( mPoints[0].p ) * TotTime.asMilliseconds() / tdist ); } for (i = 0; i < mPoints.size() - 1; i++) - mPoints[i].t = mPoints[i].p.distance( mPoints[i + 1].p ) * TotTime.asMilliseconds() / tdist; + mPoints[i].t = Milliseconds( mPoints[i].p.distance( mPoints[i + 1].p ) * TotTime.asMilliseconds() / tdist ); + + return *this; } -void Interpolation2d::setType( Ease::Interpolation InterpolationType ) { +Interpolation2d& Interpolation2d::setType( Ease::Interpolation InterpolationType ) { mType = InterpolationType; + return *this; } const int& Interpolation2d::getType() const { return mType; } +UintPtr Interpolation2d::getData() const +{ + return mData; +} + +void Interpolation2d::setData(const UintPtr & data) +{ + mData = data; +} + bool Interpolation2d::getLoop() const { return mLoop; } -void Interpolation2d::setLoop( const bool& loop ) { +Interpolation2d& Interpolation2d::setLoop( const bool& loop ) { mLoop = loop; + return *this; } bool Interpolation2d::ended() const { @@ -246,11 +287,11 @@ Point2d * Interpolation2d::getCurrentNext() const { return mNexP; } -const Uint32& Interpolation2d::getCurrentPos() const { +const Uint32& Interpolation2d::getCurrentPositionIndex() const { return mCurPoint; } -const std::vector& Interpolation2d::getWaypoints() const { +const std::vector& Interpolation2d::getPoints() const { return mPoints; } @@ -262,8 +303,9 @@ const bool& Interpolation2d::isEnabled() const { return mEnable; } -void Interpolation2d::setEnabled( const bool& Enabled ) { +Interpolation2d& Interpolation2d::setEnabled( const bool& Enabled ) { mEnable = Enabled; + return *this; } }} diff --git a/src/eepp/ui/uicontrolanim.cpp b/src/eepp/ui/uicontrolanim.cpp index 01695edb8..cb2cffe50 100644 --- a/src/eepp/ui/uicontrolanim.cpp +++ b/src/eepp/ui/uicontrolanim.cpp @@ -211,7 +211,7 @@ void UIControlAnim::update() { if ( NULL != mMoveAnim && mMoveAnim->isEnabled() ) { mMoveAnim->update( getElapsed() ); - setPosition( (int)mMoveAnim->getPos().x, (int)mMoveAnim->getPos().y ); + setPosition( (int)mMoveAnim->getPosition().x, (int)mMoveAnim->getPosition().y ); if ( mMoveAnim->ended() ) eeSAFE_DELETE( mMoveAnim ); @@ -219,7 +219,7 @@ void UIControlAnim::update() { if ( NULL != mAlphaAnim && mAlphaAnim->isEnabled() ) { mAlphaAnim->update( getElapsed() ); - setAlpha( mAlphaAnim->getRealPos() ); + setAlpha( mAlphaAnim->getPosition() ); if ( mAlphaAnim->ended() ) { if ( ( mControlFlags & UI_CTRL_FLAG_CLOSE_FO ) ) @@ -237,7 +237,7 @@ void UIControlAnim::update() { if ( NULL != mScaleAnim && mScaleAnim->isEnabled() ) { mScaleAnim->update( getElapsed() ); - setScale( mScaleAnim->getPos() ); + setScale( mScaleAnim->getPosition() ); if ( mScaleAnim->ended() ) eeSAFE_DELETE( mScaleAnim ); @@ -245,7 +245,7 @@ void UIControlAnim::update() { if ( NULL != mAngleAnim && mAngleAnim->isEnabled() ) { mAngleAnim->update( getElapsed() ); - setRotation( mAngleAnim->getRealPos() ); + setRotation( mAngleAnim->getPosition() ); if ( mAngleAnim->ended() ) eeSAFE_DELETE( mAngleAnim ); @@ -264,12 +264,7 @@ Interpolation1d * UIControlAnim::startAlphaAnim( const Float& From, const Float& if ( NULL == mAlphaAnim ) mAlphaAnim = eeNew( Interpolation1d, () ); - mAlphaAnim->clearWaypoints(); - mAlphaAnim->addWaypoint( From ); - mAlphaAnim->addWaypoint( To ); - mAlphaAnim->setTotalTime( TotalTime ); - mAlphaAnim->start( PathEndCallback ); - mAlphaAnim->setType( Type ); + mAlphaAnim->clear().add( From, TotalTime ).add( To ).setType( Type ).start( PathEndCallback ); setAlpha( From ); @@ -291,23 +286,18 @@ Interpolation1d * UIControlAnim::startAlphaAnim( const Float& From, const Float& return mAlphaAnim; } -Interpolation2d * UIControlAnim::startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) { +Interpolation2d * UIControlAnim::startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { if ( NULL == mScaleAnim ) mScaleAnim = eeNew( Interpolation2d, () ); - mScaleAnim->clearWaypoints(); - mScaleAnim->addWaypoint( From ); - mScaleAnim->addWaypoint( To ); - mScaleAnim->setTotalTime( TotalTime ); - mScaleAnim->start( PathEndCallback ); - mScaleAnim->setType( Type ); + mScaleAnim->clear().add( From ).add( To ).setTotalTime( TotalTime ).setType( Type ).start( PathEndCallback ); setScale( From ); return mScaleAnim; } -Interpolation2d * UIControlAnim::startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) { +Interpolation2d * UIControlAnim::startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { return startScaleAnim( Vector2f( From, From ), Vector2f( To, To ), TotalTime, Type, PathEndCallback ); } @@ -315,12 +305,7 @@ Interpolation2d * UIControlAnim::startTranslation( const Vector2i& From, const V if ( NULL == mMoveAnim ) mMoveAnim = eeNew( Interpolation2d, () ); - mMoveAnim->clearWaypoints(); - mMoveAnim->addWaypoint( Vector2f( (Float)From.x, (Float)From.y ) ); - mMoveAnim->addWaypoint( Vector2f( (Float)To.x, (Float)To.y ) ); - mMoveAnim->setTotalTime( TotalTime ); - mMoveAnim->start( PathEndCallback ); - mMoveAnim->setType( Type ); + mMoveAnim->clear().add( Vector2f( (Float)From.x, (Float)From.y ) ).add( Vector2f( (Float)To.x, (Float)To.y ) ).setType( Type ).setTotalTime( TotalTime ).start( PathEndCallback ); setPosition( From ); @@ -331,36 +316,51 @@ Interpolation1d * UIControlAnim::startRotation( const Float& From, const Float& if ( NULL == mAngleAnim ) mAngleAnim = eeNew( Interpolation1d, () ); - mAngleAnim->clearWaypoints(); - mAngleAnim->addWaypoint( From ); - mAngleAnim->addWaypoint( To ); - mAngleAnim->setTotalTime( TotalTime ); - mAngleAnim->start( PathEndCallback ); - mAngleAnim->setType( Type ); + mAngleAnim->clear().add( From ).add( To ).setTotalTime( TotalTime ).setType( Type ).start( PathEndCallback ); setRotation( From ); return mAngleAnim; } -Interpolation1d * UIControlAnim::createFadeIn( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - return startAlphaAnim( mAlpha, 255.f, Time, AlphaChilds, Type ); +Interpolation1d * UIControlAnim::startAlphaAnim(const Float & To, const Time & TotalTime, const bool & alphaChilds, const Ease::Interpolation & type, Interpolation1d::OnPathEndCallback PathEndCallback) { + return startAlphaAnim( mAlpha, To, TotalTime, alphaChilds, type, PathEndCallback ); } -Interpolation1d * UIControlAnim::createFadeOut( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - return startAlphaAnim( 255.f, mAlpha, Time, AlphaChilds, Type ); +Interpolation2d * UIControlAnim::startScaleAnim(const Vector2f & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { + return startScaleAnim( mScale, To, TotalTime, type, PathEndCallback ); } -Interpolation1d * UIControlAnim::closeFadeOut( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - startAlphaAnim ( mAlpha, 0.f, Time, AlphaChilds, Type ); +Interpolation2d * UIControlAnim::startScaleAnim(const Float & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { + return startScaleAnim( mScale, Vector2f(To,To), TotalTime, type, PathEndCallback ); +} + +Interpolation2d * UIControlAnim::startTranslation(const Vector2i & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { + return startTranslation( mPos, To, TotalTime, type, PathEndCallback ); +} + +Interpolation1d * UIControlAnim::startRotation(const Float & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation1d::OnPathEndCallback PathEndCallback) { + return startRotation( mAngle, To, TotalTime, type, PathEndCallback ); +} + +Interpolation1d * UIControlAnim::createFadeIn( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { + return startAlphaAnim( mAlpha, 255.f, time, AlphaChilds, Type ); +} + +Interpolation1d * UIControlAnim::createFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { + return startAlphaAnim( 255.f, mAlpha, time, AlphaChilds, Type ); +} + +Interpolation1d * UIControlAnim::closeFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { + startAlphaAnim ( mAlpha, 0.f, time, AlphaChilds, Type ); mControlFlags |= UI_CTRL_FLAG_CLOSE_FO; return mAlphaAnim; } -Interpolation1d * UIControlAnim::disableFadeOut( const Time& Time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { +Interpolation1d * UIControlAnim::disableFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { setEnabled( false ); - startAlphaAnim ( mAlpha, 0.f, Time, AlphaChilds, Type ); + startAlphaAnim ( mAlpha, 0.f, time, AlphaChilds, Type ); mControlFlags |= UI_CTRL_FLAG_DISABLE_FADE_OUT; diff --git a/src/examples/sprites/sprites.cpp b/src/examples/sprites/sprites.cpp index f41248b51..baa10a936 100644 --- a/src/examples/sprites/sprites.cpp +++ b/src/examples/sprites/sprites.cpp @@ -25,9 +25,9 @@ void spriteCallback( Uint32 Event, Sprite * Sprite, void * UserData ) { } else if ( Event == USER_SPRITE_EVENT ) { // Create an interpolation to change the angle of the sprite Interpolation1d * RotationInterpolation = reinterpret_cast( UserData ); - RotationInterpolation->clearWaypoints(); - RotationInterpolation->addWaypoint( Sprite->getRotation() ); - RotationInterpolation->addWaypoint( Sprite->getRotation() + 45.f ); + RotationInterpolation->clear(); + RotationInterpolation->add( Sprite->getRotation() ); + RotationInterpolation->add( Sprite->getRotation() + 45.f ); RotationInterpolation->setTotalTime( Milliseconds( 500 ) ); RotationInterpolation->setType( Ease::BounceOut ); // Set the easing effect used for the interpolation RotationInterpolation->start(); @@ -64,8 +64,8 @@ void mainLoop() RockAngle.update( win->getElapsed() ); // Set the Planet and Rock angle from the interpolation - Planet.setRotation( PlanetAngle.getPos() ); - Rock.setRotation( RockAngle.getPos() ); + Planet.setRotation( PlanetAngle.getPosition() ); + Rock.setRotation( RockAngle.getPosition() ); // Draw the static planet sprite Planet.draw(); @@ -149,8 +149,8 @@ EE_MAIN_FUNC int main (int argc, char * argv []) ScreenCenter.y - Blindy.getAABB().getSize().getHeight() / 2 ) ); // Set the planet angle interpolation - PlanetAngle.addWaypoint( 0 ); - PlanetAngle.addWaypoint( 360 ); + PlanetAngle.add( 0 ); + PlanetAngle.add( 360 ); PlanetAngle.setTotalTime( Seconds( 10 ) ); PlanetAngle.setLoop( true ); PlanetAngle.start(); diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 3b1b9c58d..15a3fe7b5 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -188,13 +188,13 @@ void EETest::init() { } WP.setType( Ease::QuarticInOut ); - WP.addWaypoint( Vector2f(0,0), 100 ); - WP.addWaypoint( Vector2f(800,0), 100 ); - WP.addWaypoint( Vector2f(0,0), 100 ); - WP.addWaypoint( Vector2f(1024,768), 100 ); - WP.addWaypoint( Vector2f(0,600), 100 ); - WP.editWaypoint( 2, Vector2f(800,600), 100 ); - WP.eraseWaypoint( 3 ); + WP.add( Vector2f(0,0), Milliseconds(100) ); + WP.add( Vector2f(800,0), Milliseconds(100) ); + WP.add( Vector2f(0,0), Milliseconds(100) ); + WP.add( Vector2f(1024,768), Milliseconds(100) ); + WP.add( Vector2f(0,600), Milliseconds(100) ); + WP.edit( 2, Vector2f(800,600), Milliseconds(100) ); + WP.erase( 3 ); WP.setLoop(true); WP.setTotalTime( Milliseconds( 5000 ) ); WP.start(); @@ -1495,7 +1495,7 @@ void EETest::screen2() { WP.update( et ); PR.setColor( Color(0, 255, 0, 255) ); - PR.drawPoint( WP.getPos(), 10.f ); + PR.drawPoint( WP.getPosition(), 10.f ); } void EETest::screen3() {