本文整理汇总了C++中Anim::ParseFromTokens方法的典型用法代码示例。如果您正苦于以下问题:C++ Anim::ParseFromTokens方法的具体用法?C++ Anim::ParseFromTokens怎么用?C++ Anim::ParseFromTokens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anim
的用法示例。
在下文中一共展示了Anim::ParseFromTokens方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Parse
/// @todo Repair major memory leaks when returning FALSE
sint32 UnitSpriteGroup::Parse(uint16 id, GROUPTYPE type)
{
MBCHAR scriptName[k_MAX_NAME_LENGTH];
MBCHAR *facedImageNames[k_NUM_FACINGS][k_MAX_NAMES];
MBCHAR *facedShadowNames[k_NUM_FACINGS][k_MAX_NAMES];
MBCHAR *imageNames[k_MAX_NAMES];
MBCHAR *shadowNames[k_MAX_NAMES];
size_t i;
size_t j;
char prefixStr[80];
for (j=0; j<k_NUM_FACINGS; j++)
{
for (i=0; i<k_MAX_NAMES; i++)
{
facedImageNames[j][i] = new MBCHAR[2 * k_MAX_NAME_LENGTH];
facedShadowNames[j][i] = new MBCHAR[2 * k_MAX_NAME_LENGTH];
}
}
for (i=0; i<k_MAX_NAMES; i++)
{
imageNames[i] = new MBCHAR[2 * k_MAX_NAME_LENGTH];
shadowNames[i] = new MBCHAR[2 * k_MAX_NAME_LENGTH];
}
sprintf(prefixStr, ".%s%d%s", FILE_SEP, id, FILE_SEP);
if (type == GROUPTYPE_UNIT)
{
sprintf(scriptName, "GU%.3d.txt", id);
if (!c3files_PathIsValid(scriptName))
sprintf(scriptName, "GU%.2d.txt", id);
}
else
sprintf(scriptName, "GC%.3d.txt", id);
printf("Processing '%s'\n", scriptName);
Token * theToken = new Token(scriptName, C3DIR_SPRITES);
Assert(theToken);
if (!theToken) return FALSE;
sint32 tmp;
if (!token_ParseKeywordNext(theToken, TOKEN_UNIT_SPRITE)) return FALSE;
if (!token_ParseAnOpenBraceNext(theToken)) return FALSE;
if (!token_ParseValNext(theToken, TOKEN_UNIT_SPRITE_MOVE, tmp)) return FALSE;
if (tmp)
{
Assert(type == GROUPTYPE_UNIT);
if (type != GROUPTYPE_UNIT)
{
printf("\n Illegal unit action (Move) for a city sprite.\n");
return FALSE;
}
FacedSprite *moveSprite = new FacedSprite;
moveSprite->ParseFromTokens(theToken);
printf(" [Move");
for (j=0; j<k_NUM_FACINGS; j++)
{
for (size_t k = 0; k < moveSprite->GetNumFrames(); ++k)
{
if (!GetImageFileName(facedShadowNames[j][k],"%sGU%#.3dMS%d.%d", prefixStr, id, j+1, k+moveSprite->GetFirstFrame()))
GetImageFileName(facedShadowNames[j][k] ,"%sGU%#.2dMS%d.%d", prefixStr, id, j+1, k+moveSprite->GetFirstFrame());
if (!GetImageFileName(facedImageNames[j][k], "%sGU%#.3dMA%d.%d", prefixStr, id, j+1, k+moveSprite->GetFirstFrame()))
GetImageFileName(facedImageNames[j][k] , "%sGU%#.2dMA%d.%d", prefixStr, id, j+1, k+moveSprite->GetFirstFrame());
}
}
moveSprite->Import(moveSprite->GetNumFrames(), facedImageNames, facedShadowNames);
delete m_sprites[UNITACTION_MOVE];
m_sprites[UNITACTION_MOVE] = moveSprite;
printf("]\n");
Anim *moveAnim = new Anim;
moveAnim->ParseFromTokens(theToken);
delete m_anims[UNITACTION_MOVE];
m_anims[UNITACTION_MOVE] = moveAnim;
//.........这里部分代码省略.........