add ActorFrame::SortByZ
This commit is contained in:
@@ -62,10 +62,8 @@ void ActorFrame::DrawPrimitives()
|
||||
void ActorFrame::Update( float fDeltaTime )
|
||||
{
|
||||
// LOG->Trace( "ActorFrame::Update( %f )", fDeltaTime );
|
||||
|
||||
Actor::Update( fDeltaTime );
|
||||
|
||||
|
||||
// update all sub-Actors
|
||||
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
||||
m_SubActors[i]->Update(fDeltaTime);
|
||||
@@ -101,3 +99,30 @@ float ActorFrame::GetTweenTimeLeft() const
|
||||
|
||||
}
|
||||
|
||||
void ActorFrame::SortByZ()
|
||||
{
|
||||
// Sort to have descending Z values so we draw back to front.
|
||||
// STL sort()s typically use qsort, which won't preserve
|
||||
// ordering of Actors with equal Z values.
|
||||
// Sort it ourselves. -Chris
|
||||
vector<Actor*> v;
|
||||
for( unsigned i=0; i<m_SubActors.size(); i++ )
|
||||
{
|
||||
Actor* pToInsert = m_SubActors[i];
|
||||
|
||||
for( unsigned j=0; j<v.size(); j++ )
|
||||
if( pToInsert->GetZ() > v[j]->GetZ() )
|
||||
{
|
||||
v.insert( v.begin()+j, pToInsert );
|
||||
break;
|
||||
}
|
||||
|
||||
if( j == v.size() )
|
||||
v.push_back( pToInsert );
|
||||
}
|
||||
|
||||
for( unsigned j=0; j<v.size(); j++ )
|
||||
printf( "%.0f ", v[j]->GetZ() );
|
||||
|
||||
m_SubActors = v;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
virtual void AddChild( Actor* pActor );
|
||||
virtual void MoveToTail( Actor* pActor );
|
||||
virtual void MoveToHead( Actor* pActor );
|
||||
virtual void SortByZ();
|
||||
|
||||
virtual ~ActorFrame() { }
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#define ON_COMMAND( actor ) UtilOnCommand( actor, m_sName );
|
||||
#define OFF_COMMAND( actor ) UtilOffCommand( actor, m_sName );
|
||||
#define SET_XY_AND_ON_COMMAND( actor ) UtilSetXYAndOnCommand( actor, m_sName );
|
||||
#define COMMAND( actor, command_name ) UtilCommand( actor, m_sName, command_name );
|
||||
|
||||
|
||||
inline void UtilSetXY( Actor& actor, CString sClassName )
|
||||
@@ -30,6 +31,11 @@ inline void UtilOnCommand( Actor& actor, CString sClassName )
|
||||
actor.Command( THEME->GetMetric(sClassName,actor.GetName()+"OnCommand") );
|
||||
}
|
||||
|
||||
inline void UtilCommand( Actor& actor, CString sClassName, CString sCommandName )
|
||||
{
|
||||
actor.Command( THEME->GetMetric(sClassName,actor.GetName()+sCommandName+"Command") );
|
||||
}
|
||||
|
||||
inline void UtilOffCommand( Actor& actor, CString sClassName )
|
||||
{
|
||||
// HACK: It's very often that we command things to TweenOffScreen
|
||||
|
||||
Reference in New Issue
Block a user