当前位置: 首页>>代码示例>>C++>>正文


C++ Anim::ParseFromTokens方法代码示例

本文整理汇总了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;
//.........这里部分代码省略.........
开发者ID:talentlesshack,项目名称:C2P2,代码行数:101,代码来源:UnitSpriteGroup.cpp


注:本文中的Anim::ParseFromTokens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。