Browse Source

- Fixed issue#28 where a specified sprite name was not assigned. Additionally this is now assigned during a Taml read operation. (https://github.com/GarageGames/Torque2D/issues/28)

MelvMay-GG 12 years ago
parent
commit
2e230e4
1 changed files with 14 additions and 0 deletions
  1. 14 0
      engine/source/2d/core/SpriteBatch.cc

+ 14 - 0
engine/source/2d/core/SpriteBatch.cc

@@ -907,6 +907,9 @@ void SpriteBatch::setSpriteName( const char* pName )
     if ( findSpriteName( pName ) )
         return;
 
+    // Insert sprite name.
+    mSpriteNames.insert( StringTable->insert( pName ), mSelectedSprite );
+
     // Set name.
     mSelectedSprite->setName( pName );
 }
@@ -1224,6 +1227,17 @@ void SpriteBatch::onTamlCustomRead( const TamlCustomNode* pSpritesNode )
             // Yes, so insert into sprite positions.
             mSpritePositions.insert( logicalPosition, pSpriteBatchItem );
         }
+
+        // Fetch sprite name.
+        StringTableEntry spriteName = pSpriteBatchItem->getName();
+
+        // Did we get a sprite name?
+        if ( spriteName != StringTable->EmptyString )
+        {
+            // Yes, so insert into sprite names if it doesn't already exist.
+            if ( mSpriteNames.find( spriteName ) != mSpriteNames.end() ) 
+                mSpriteNames.insert( spriteName, mSelectedSprite );
+        }
     }
 }