Make Transition an ActorFrame, so commands are propagated to the
actual BGA. Add Reset(), to allow transitioning a Transition more than once (less likely to cause problems than automatically resetting to "waiting" after the transition finishes).
This commit is contained in:
@@ -16,10 +16,14 @@ void Transition::Load( CString sBGAniDir )
|
|||||||
if( !sBGAniDir.empty() && sBGAniDir.Right(1) != "/" )
|
if( !sBGAniDir.empty() && sBGAniDir.Right(1) != "/" )
|
||||||
sBGAniDir += "/";
|
sBGAniDir += "/";
|
||||||
|
|
||||||
|
bool bWasLoaded = m_sprTransition.IsLoaded();
|
||||||
m_sprTransition.Load( sBGAniDir );
|
m_sprTransition.Load( sBGAniDir );
|
||||||
m_sprTransition->PlayCommand( "On" );
|
m_sprTransition->PlayCommand( "On" );
|
||||||
m_fLengthSeconds = m_sprTransition->GetTweenTimeLeft();
|
m_fLengthSeconds = m_sprTransition->GetTweenTimeLeft();
|
||||||
|
|
||||||
|
if( !bWasLoaded )
|
||||||
|
this->AddChild( m_sprTransition );
|
||||||
|
|
||||||
m_State = waiting;
|
m_State = waiting;
|
||||||
|
|
||||||
// load sound from file specified by ini, or use the first sound in the directory
|
// load sound from file specified by ini, or use the first sound in the directory
|
||||||
@@ -51,15 +55,21 @@ void Transition::Update( float fDeltaTime )
|
|||||||
if( m_bFirstUpdate )
|
if( m_bFirstUpdate )
|
||||||
m_sound.PlayRandom();
|
m_sound.PlayRandom();
|
||||||
|
|
||||||
Actor::Update( fDeltaTime );
|
// Check this before running Update, so we draw the last frame of the finished
|
||||||
|
// transition before sending m_MessageToSendWhenDone.
|
||||||
if( m_sprTransition->GetTweenTimeLeft() == 0 ) // over
|
if( m_sprTransition->GetTweenTimeLeft() == 0 ) // over
|
||||||
{
|
{
|
||||||
SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone );
|
|
||||||
m_State = finished;
|
m_State = finished;
|
||||||
|
SCREENMAN->SendMessageToTopScreen( m_MessageToSendWhenDone );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sprTransition->Update( fDeltaTime );
|
ActorFrame::Update( fDeltaTime );
|
||||||
|
}
|
||||||
|
|
||||||
|
void Transition::Reset()
|
||||||
|
{
|
||||||
|
ASSERT( m_State == finished );
|
||||||
|
m_State = waiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transition::EarlyAbortDraw()
|
bool Transition::EarlyAbortDraw()
|
||||||
@@ -67,11 +77,6 @@ bool Transition::EarlyAbortDraw()
|
|||||||
return m_State != transitioning;
|
return m_State != transitioning;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transition::DrawPrimitives()
|
|
||||||
{
|
|
||||||
m_sprTransition->Draw();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Transition::StartTransitioning( ScreenMessage send_when_done )
|
void Transition::StartTransitioning( ScreenMessage send_when_done )
|
||||||
{
|
{
|
||||||
if( m_State != waiting )
|
if( m_State != waiting )
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
#ifndef TRANSITION_H
|
#ifndef TRANSITION_H
|
||||||
#define TRANSITION_H
|
#define TRANSITION_H
|
||||||
|
|
||||||
#include "Actor.h"
|
#include "ActorFrame.h"
|
||||||
#include "AutoActor.h"
|
#include "AutoActor.h"
|
||||||
#include "ScreenMessage.h"
|
#include "ScreenMessage.h"
|
||||||
#include "RandomSample.h"
|
#include "RandomSample.h"
|
||||||
|
|
||||||
|
|
||||||
class Transition : public Actor
|
class Transition : public ActorFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Transition();
|
Transition();
|
||||||
@@ -17,11 +17,11 @@ public:
|
|||||||
void Load( CString sBGAniDir );
|
void Load( CString sBGAniDir );
|
||||||
|
|
||||||
virtual void Update( float fDeltaTime );
|
virtual void Update( float fDeltaTime );
|
||||||
virtual void DrawPrimitives();
|
|
||||||
|
|
||||||
virtual void StartTransitioning( ScreenMessage send_when_done = SM_None );
|
virtual void StartTransitioning( ScreenMessage send_when_done = SM_None );
|
||||||
virtual bool EarlyAbortDraw();
|
virtual bool EarlyAbortDraw();
|
||||||
virtual float GetTweenTimeLeft() const;
|
virtual float GetTweenTimeLeft() const;
|
||||||
|
void Reset(); // explicitly allow transitioning again
|
||||||
|
|
||||||
bool IsTransitioning() const { return m_State == transitioning; };
|
bool IsTransitioning() const { return m_State == transitioning; };
|
||||||
bool IsFinished() const { return m_State == finished; };
|
bool IsFinished() const { return m_State == finished; };
|
||||||
|
|||||||
Reference in New Issue
Block a user