Game Development Community

About create a CompositeSprite from a taml file...

by KevinYuen · in Torque 2D Beginner · 04/23/2013 (5:43 am) · 2 replies

The taml file is like this:
<CompositeSprite
    SceneLayer="1"
    Awake="0"
    BatchIsolated="1"
    BatchSortMode="New"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="torque.xsd">
    <CompositeSprite.Sprites>
        <Sprite
            Name="Ground"
            Image="GoldenFlowerAssets:CardTemplate01"
            Frame="0"
            Position="0 0"
            Size="15 20" />
        <Sprite
            Name="MainMarker"
            Image="GoldenFlowerAssets:CardBigFlagFire"
            Frame="0"
            Position="0 0"
            Size="10 15" />
    </CompositeSprite.Sprites>
</CompositeSprite>

In my project:

%object = TamlRead( "^MyProjectAssets/test.taml" );
    Game.MainScene.add( %object );
    %ret = %object.selectSpriteName( "MainMarker" );

Output in console:
Cannot select sprite name 'MainMarker' as it does not exist.

If i create a it in code directly, it work well.

#1
04/24/2013 (6:29 am)
I maybe found question about this bug..

// 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 );
}

modify....

// 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, pSpriteBatchItem );
}

It's a bug. please update git :)
#2
04/24/2013 (8:51 am)
You should post a pull request when you have a bug fix.