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


C++ CAnimation::SetIsLooping方法代码示例

本文整理汇总了C++中CAnimation::SetIsLooping方法的典型用法代码示例。如果您正苦于以下问题:C++ CAnimation::SetIsLooping方法的具体用法?C++ CAnimation::SetIsLooping怎么用?C++ CAnimation::SetIsLooping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CAnimation的用法示例。


在下文中一共展示了CAnimation::SetIsLooping方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadSingleAnimation

CAnimation* CAnimationManager::LoadSingleAnimation(string szFileName, string szImageName)
{

    CAnimation* Anim = new CAnimation();

    TiXmlDocument doc;
    // Adding Paths to filename for animations
    string szPath = "resource/animations/";
    szPath += szFileName;

    string szImagePath = "resource/graphics/";
    szImagePath += szImageName;

    do
    {
        if( doc.LoadFile(szPath.c_str() ) == false )
            break;

        TiXmlElement* pRoot = doc.RootElement();

        if( !pRoot )
            break;

        TiXmlElement* pAnim = pRoot->FirstChildElement("Animation");

        if( pAnim == NULL )
            break;


        while( pAnim )
        {

            TiXmlElement* pNewAnim = pAnim;

            //***************Animation IsLooping**********************//
            if( pNewAnim->Attribute("IsLooping") == NULL )
                break;

            int dIsLooping = 0;

            pNewAnim->Attribute("IsLooping", &dIsLooping);

            if( dIsLooping != 0 )
                Anim->SetIsLooping(true);
            else
                Anim->SetIsLooping(false);


            Anim->SetImageID(CSGD_TextureManager::GetInstance()->LoadTexture(szImagePath.c_str() ) );

            //********************Animation Name*************************//

            if( pNewAnim->Attribute("Name") == NULL )
                break;

            const char* szName;

            szName = pNewAnim->Attribute("Name");
            Anim->SetName(szName);

            TiXmlElement* pFrame = pNewAnim->FirstChildElement("Frames");

            if( pFrame == NULL )
                break;

            // Animation Frames
            while( pFrame )
            {
                CFrame* Frame = new CFrame();
                TiXmlElement* pNewFrame = pFrame;
                ////*****************Setting Height*********************************//

                if( pNewFrame->Attribute("Height") == NULL )
                    break;

                double dHeight = 0.0;
                pNewFrame->Attribute("Height",&dHeight);
                Frame->SetHeight((int)dHeight);

                ////*******************Setting Width*******************************//

                if( pNewFrame->Attribute("Width") == NULL )
                    break;

                double dWidth = 0.0;
                pNewFrame->Attribute("Width",&dWidth);
                Frame->SetWidth((int)dWidth);

                //*****************Setting Anchor X*********************************//

                if( pNewFrame->Attribute("AnchorX") == NULL)
                    break;

                double dAnchorX = 0.0;
                pNewFrame->Attribute("AnchorX",&dAnchorX);
                Frame->SetAnchorX((int)dAnchorX);

                ////*******************Setting Anchor Y*******************************//

                if( pNewFrame->Attribute("AnchorY") == NULL )
//.........这里部分代码省略.........
开发者ID:CSPshala,项目名称:BeatWars,代码行数:101,代码来源:CAnimationManager.cpp

示例2: LoadAnimation

int CAnimationManager::LoadAnimation(const char* szFileName, int* pnFirstAnmID, int* pnLastAnmID)
{
	if(pnFirstAnmID)
		*pnFirstAnmID = -1;
	if(pnLastAnmID)
		*pnLastAnmID = -1;

	TiXmlDocument doc;
	if(doc.LoadFile(szFileName) == false)
		return false;

	TiXmlElement* pRoot = doc.RootElement();

	if(!pRoot)
		return false;
	string filepath;
	filepath.append("resource/");

	const char* pDir;
	if(pRoot->Attribute("FileName"))
	{
		pDir = pRoot->Attribute("FileName");
		char buffer[128] = {0};
		strcpy_s(buffer,_countof(buffer),pDir);
		filepath.append(pDir);
	}
	int nAnimationSheet = TEX_MNG->LoadTexture(filepath.c_str(),D3DCOLOR_XRGB(255,0,255));
	
	TiXmlElement* pAnimation = pRoot->FirstChildElement("Animation");
	while(pAnimation)
	{

		CAnimation* tempAnimation = new CAnimation;
		int nTemp = 0;
		double dTemp = 0.0;
		const char* pName;
		if(pAnimation->Attribute("name"))
		{
			pName = pAnimation->Attribute("name");
			char buffer[128] = {0};
			strcpy_s(buffer,_countof(buffer),pName);
			tempAnimation->SetName(buffer);
		}

		if(pAnimation->QueryIntAttribute("looping",&nTemp) != TIXML_NO_ATTRIBUTE)
		{
			tempAnimation->SetIsLooping((nTemp==1)?true:false);
		}

		if(pAnimation->QueryIntAttribute("oslating",&nTemp) != TIXML_NO_ATTRIBUTE)
		{
			tempAnimation->SetIsOscillating((nTemp==1)?true:false);
		}
		if(pAnimation->QueryIntAttribute("playing",&nTemp) != TIXML_NO_ATTRIBUTE)
		{
			tempAnimation->SetIsPlaying((nTemp==1)?true:false);
		}
		if(pAnimation->QueryDoubleAttribute("speed",&dTemp) != TIXML_NO_ATTRIBUTE)
		{
			tempAnimation->SetSpeed(dTemp);
		}
		TiXmlElement* pFrame = pAnimation->FirstChildElement("Frame");
		while (pFrame)
		{
			CFrame tempFrame;
			if(pFrame->QueryDoubleAttribute("duration",&dTemp) != TIXML_NO_ATTRIBUTE)
			{
				tempFrame.SetDuration(dTemp);
			}

			const char* pEvent;
			if(pFrame->Attribute("event"))
			{
				pEvent = pFrame->Attribute("event");
				tempFrame.SetEvent(pEvent);
			}

			//	Get the draw rect
			TiXmlElement* pDrawRect = pFrame->FirstChildElement("DrawRect");

			RectD tempDrawRect;
			if(pDrawRect->QueryIntAttribute("x",&nTemp) != TIXML_NO_ATTRIBUTE)
			{
				tempDrawRect.left = nTemp;
			}
			if(pDrawRect->QueryIntAttribute("y",&nTemp) != TIXML_NO_ATTRIBUTE)
			{
				tempDrawRect.top = nTemp;
			}
			if(pDrawRect->QueryIntAttribute("width",&nTemp) != TIXML_NO_ATTRIBUTE)
			{
				tempDrawRect.right = tempDrawRect.left + nTemp;
			}
			if(pDrawRect->QueryIntAttribute("height",&nTemp) != TIXML_NO_ATTRIBUTE)
			{
				tempDrawRect.bottom = tempDrawRect.top + nTemp;
			}
			//	Set the Draw Rect
			tempFrame.SetDrawRect(tempDrawRect);

//.........这里部分代码省略.........
开发者ID:namlunthkl,项目名称:team4-trynity,代码行数:101,代码来源:CAnimationManager.cpp


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