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


C++ CSprite::SetPosition方法代码示例

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


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

示例1: Render

void CBoard::Render()
{
    if (m_pBoard)
    {
        m_pBoard->Render();
    }

    for (int i = 0; i < 9; i++)
    {
        int x = i / 3;
        int y = i % 3;

        if ( IsTileFree( x, y ) )
        {
            continue;
        }

        CSprite *pIcon = m_iMatrix[x][y] == PLAYER_X ? m_pX : m_pO;

        if (!pIcon)
        {
            continue;
        }

        pIcon->SetPosition( (x-1)*DELTA_WIDTH, (y-1)*DELTA_HEIGHT );
        pIcon->SetScale( SCALE );

        pIcon->Render();
    }
}
开发者ID:Islandstone,项目名称:Magnificent-Game-Engine,代码行数:30,代码来源:board.cpp

示例2: Init

// This is where the bones of the project are forged
// (loading sprites, for example)
BOOL CGameLogic::Init(CGame *game)
{
	// Initialize the combination
	m_combo = CreateCombination();
	m_nodes = m_combo;
	for (unsigned i = 0; i < m_nodes.size(); i++)
		m_nodes[i] = i;

	// Load sprites
	auto path = game->GetExecutablePath();

	// Slider (Mid-section)
	CSprite *spr = nullptr;
	if (!LoadSprite(path, L"sliderMid.png", game->GetRenderer(), &spr))
		return FALSE;
	m_sprites.push_back(spr);
	spr->SetPosition(0, 0);

	// Slider (nodes)
	for (auto i = 0; i < 5; i++) {
		spr = nullptr;
		if (!LoadSprite(path, L"sliderNode.png", game->GetRenderer(), &spr))
			return FALSE;
		m_sprites.push_back(spr);
	}

	return TRUE;
}
开发者ID:MichaelSpectre,项目名称:FireMarblePuzzle,代码行数:30,代码来源:GameLogic.cpp

示例3: Render

// ----------------------------------------------------------------
//	Render
// ----------------------------------------------------------------
void CAnimation::Render()
{
	CSprite * sprite;

	if( m_Fps == 0 )
		sprite = m_Sprites[0];
	else
		sprite = m_Sprites[m_FrameNumber];

	sprite->SetPosition( m_Position );
	sprite->Render();
}
开发者ID:blastingzone,项目名称:meteor,代码行数:15,代码来源:Animation.cpp

示例4: LoadSprites

int CLoader::LoadSprites()
{
	eRoot = xmlDoc.RootElement()->FirstChildElement( "Content" );
	if(eRoot == 00) return -1;

	eSprites = eRoot->FirstChildElement( "Sprites" );
	if(eSprites == 00) return -1;

	eSprite = eSprites->FirstChildElement( "Sprite" );
	if(eSprite == 00) return -1;

	string sTempSpriteName, sTempFilename, sSpriteStatus;
	int xPosTemp, yPosTemp, zPosTemp;
	bool bSpriteActive;

	while(eSprite != 00)
	{
		eContent = eSprite;

		eContent = eContent->FirstChildElement( "spriteName" );
		if(eContent == 00) break;
		sTempSpriteName = converter::CharToString( eContent->GetText() );

		eContent = eContent->NextSiblingElement( "filename" );
		if(eContent == 00) break;
		sTempFilename = converter::CharToString( eContent->GetText() );

		eContent = eContent->NextSiblingElement( "status" );
		if(eContent == 00) break;
		sSpriteStatus = converter::CharToString( eContent->GetText() );

		eContent = eContent->NextSiblingElement( "active" );
		if(eContent == 00) break;
		bSpriteActive = converter::IntToBool( static_cast<int>(atoi( eContent->GetText() )) );

		eContent = eContent->NextSiblingElement( "posX" );
		if(eContent == 00) break;
		xPosTemp = static_cast<int>(atoi( eContent->GetText() ));

		eContent = eContent->NextSiblingElement( "posY" );
		if(eContent == 00) break;
		yPosTemp = static_cast<int>(atoi( eContent->GetText() ));

		eContent = eContent->NextSiblingElement( "posZ" );
		if(eContent == 00) break;
		zPosTemp = static_cast<int>(atoi( eContent->GetText() ));

		CSprite* sprite = theSpriteManager->AddSprite( sTempFilename, sTempSpriteName );
		sprite->SetPosition( XMFLOAT3( xPosTemp, yPosTemp, zPosTemp ) );

		sprite->SetStatus( sSpriteStatus );
		sprite->SetActive( bSpriteActive );

		sprite = 00;
		eSprite = eSprite->NextSiblingElement( "Sprite" );
	}

	eContent = 00;
	eSprite = 00;
	eSprites = 00;
	eRoot = 00;

	return ERR_SUCCESS;
}
开发者ID:dominik-uebele,项目名称:E1,代码行数:64,代码来源:Loader.cpp

示例5: main

int main()
{
	_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
	
	glfwInit();
	
	glfwWindowHint(GLFW_SAMPLES, 4);
	window = glfwCreateWindow(WWIDTH, WHEIGHT, "GL Framework", NULL, NULL);
	glfwSetWindowSizeCallback(window, glfw_window_size_callback);
	
	glfwMakeContextCurrent(window);

	// start GLEW extension handler
	glewExperimental = GL_TRUE;
	glewInit();

	glViewport(0, 0, g_gl_width, g_gl_height);	

	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);


	// Initializam spriteManagerul
	CSpriteManager::Get()->Init();

	// Initializam PlayerEntity si creem sprite-ul asociat
	PlayerTest PlayerEntity;


	CSprite *back = CSpriteManager::Get()->AddSprite("sky0000.png", background);

	
	for (int k = 0; k < 3; k++){
		lives.push_back(CSpriteManager::Get()->AddSprite("mini.png", mini));
		lives[lives.size() - 1]->SetPosition(glm::vec3(3 + k*0.3f, 3.4f, -19));
	}

	CSprite* lifeSprite = CSpriteManager::Get()->AddSprite("life.png", textLife);
	lifeSprite->SetPosition(glm::vec3(3 - 0.6f, 3.4f, -19));



	CSprite *playerSprite = CSpriteManager::Get()->AddSprite("player0000.png", player);
	
	back->SetPosition(glm::vec3(-4, -4, -20));

	assert(playerSprite);
	PlayerEntity.Init(playerSprite);
//	back->PlayAnimation("Sky");

	EnemyTest vec[100];
	int number_of_enemy =5;
	//vector de inamici
	vector<CSprite*> enemies;
	float x,y;
	for (int i = 0; i< number_of_enemy; i++)
	{
		
		CSprite *RandomRocket = CSpriteManager::Get()->AddSprite("PlayerRocket.png",enemy);
		x = -3.0f - i;
		y = RandomRocket->getFirstParabolaY(x);
		RandomRocket->SetPosition(glm::vec3(x, y, -11));
		vec[i].Init(RandomRocket);
		enemies.push_back(RandomRocket);


	}


	float t = 0.0f;
	float dt = 0.01f;

	float prevTime =(float) glfwGetTime();
	float accumulator = 0.0f;

	Collision *collide = new Collision();
	

	bool hit = false;
	bool hit2 = false;
	int i;
	while (!glfwWindowShouldClose(window))
	{

		_update_fps_counter(window);

		float newTime =(float) glfwGetTime();
		float deltaTime = (float)(newTime - prevTime);
		

		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		glViewport(0, 0, g_gl_width, g_gl_height);


		if (deltaTime > 0.25f)
			deltaTime = 0.25f;
		prevTime = newTime;

		accumulator += deltaTime;

//.........这里部分代码省略.........
开发者ID:BiancaTud,项目名称:Ubisoft,代码行数:101,代码来源:Main.cpp

示例6: Update

	// In functia de update:
	// 1.Detectam directia de deplasare a player-ului in functie de tastele apasate
	// 2.Determinam animatia ce trebuie afisata
	// 3.Limitam din topor spatiul in care se poate deplasa player-ul
	void Update(float dt)
	{

		glm::vec3 pos;
		glm::vec3 dir(0.0f, 0.0f, 0.0f);
		bool recalculate_position = false;

		// Determinarea animatiilor si a directiei de deplasare
		if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_LEFT))
		{
			if (m_CurrentAnimType != LEFT)
			{
				m_Sprite->PlayAnimation("Left");
				m_CurrentAnimType = LEFT;
			}

			dir.x = -1.0f;
			recalculate_position = true;

		}
		if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_RIGHT))
		{
			if (m_CurrentAnimType != RIGHT)
			{
				m_Sprite->PlayAnimation("Right");
				m_CurrentAnimType = RIGHT;
			}

			dir.x = 1.0f;
			recalculate_position = true;
		}
		if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_UP))
		{
			if (m_CurrentAnimType != IDLE)
			{
				m_Sprite->PlayAnimation("Idle");
				m_CurrentAnimType = IDLE;
			}

			dir.y = 1.0f;
			recalculate_position = true;

		}
		if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_DOWN))
		{
			if (m_CurrentAnimType != IDLE)
			{
				m_Sprite->PlayAnimation("Idle");
				m_CurrentAnimType = IDLE;
			}

			dir.y = -1.0f;
			recalculate_position = true;
		}

		if (GLFW_PRESS == glfwGetKey(window, GLFW_KEY_SPACE) && semafor) {
			CSpriteManager::Get()->projectiles.push_back(CSpriteManager::Get()->AddSprite("projectile.png", player_proj));
			CSpriteManager::Get()->projectiles[CSpriteManager::Get()->projectiles.size() - 1]->SetPosition(glm::vec3(m_Sprite->GetPosition().x, m_Sprite->GetPosition().y+0.8f, -14));
			semafor = false;
		}

		if (GLFW_RELEASE == glfwGetKey(window, GLFW_KEY_SPACE) && !semafor) {
			semafor = true;
		}



		pos = m_Sprite->GetPosition();

		if (recalculate_position)
		{
			dir = glm::normalize(dir);
			pos = pos + dir * PLAYER_MOVE_SPEED * dt;
		}
		else
		{
			if (m_CurrentAnimType != IDLE)
			{
				m_Sprite->PlayAnimation("Idle");
				m_CurrentAnimType = IDLE;
			}

		}
		// END



		// Limitarea playerului 
		if (pos.x < SCREEN_LEFT)
		{
			pos.x = SCREEN_LEFT + 0.01f;
		}
		if (pos.x  > SCREEN_RIGHT - 0.4f)
		{
			pos.x = SCREEN_RIGHT - 0.4f;
		}
//.........这里部分代码省略.........
开发者ID:BiancaTud,项目名称:Ubisoft,代码行数:101,代码来源:Main.cpp

示例7: Update

void SampleScene::Update(float dt)
{
	g_Keyboard->Update() ;
	g_Mouse->Update() ;
	g_Joystick->Update() ;
	g_MusicManager->Loop() ;

	static float x=0.0f, y=0.0f ;

	if(g_Keyboard->IsButtonDown(DIK_UP))
	{
		y += 1.5f ;
	}
	if(g_Keyboard->IsButtonDown(DIK_DOWN))
	{
		y -= 1.5f ;
	}
	if(g_Keyboard->IsButtonDown(DIK_RIGHT))
	{
		x += 1.5f ;
	}
	if(g_Keyboard->IsButtonDown(DIK_LEFT))
	{
		x -= 1.5f ;
	}

	if(g_Keyboard->IsButtonDown(DIK_1))
	{
		Sprite.SetTextureUV(0.0f, 0.0f, 50.0f, 50.0f) ;
	}
	if(g_Keyboard->IsButtonDown(DIK_2))
	{
		Sprite.SetTextureUV(50.0f, 0.0f, 100.0f, 50.0f) ;
	}
	if(g_Keyboard->IsButtonDown(DIK_3))
	{
		Sprite.SetTextureUV(0.0f, 50.0f, 50.0f, 100.0f) ;
	}
	if(g_Keyboard->IsButtonDown(DIK_4))
	{
		Sprite.SetTextureUV(50.0f, 50.0f, 100.0f, 100.0f) ;
	}

	if(g_Keyboard->IsButtonDown(DIK_8))
	{
		Sprite.SetPositionZ(0.0f) ;
	}
	if(g_Keyboard->IsButtonDown(DIK_9))
	{
		Sprite.SetPositionZ(1.0f) ;
	}
	if(g_Keyboard->IsButtonDown(DIK_0))
	{
		Sprite.SetPositionZ(0.5f) ;
	}

	if(g_Keyboard->IsButtonDown(DIK_5))
	{
		UISprite.SetPositionZ(0.0f) ;
		UISprite2.SetPositionZ(0.0f) ;
	}
	if(g_Keyboard->IsButtonDown(DIK_6))
	{
		UISprite.SetPositionZ(1.0f) ;
		UISprite2.SetPositionZ(0.0f) ;
	}
	if(g_Keyboard->IsButtonDown(DIK_7))
	{
		UISprite.SetPositionZ(0.0f) ;
		UISprite2.SetPositionZ(1.0f) ;
	}

	if(g_Keyboard->IsButtonDown(DIK_F1))
	{
		g_CameraManager->SetCamera(0) ;
	}
	if(g_Keyboard->IsButtonDown(DIK_F2))
	{
		g_CameraManager->SetCamera(1) ;
	}
	
	if(g_Mouse->IsMouse(g_Mouse->LBUTTON_DOWN))
	{
		g_MusicManager->PlayMusic(sound[0]) ;
	}
	if(g_Mouse->IsMouse(g_Mouse->RBUTTON_DOWN))
	{
		g_MusicManager->PlayMusic(sound[2]) ;
	}
	if(g_Keyboard->IsButtonDown(DIK_SPACE))
	{
		g_MusicManager->PlayMusic(sound[1]) ;
	}

	/*if(g_Mouse->IsMouse(g_Mouse->LBUTTON_DOWN))
	{
		MessageBox(NULL, "LBUTTON_DOWN", "LBUTTON_DOWN", MB_OK) ;
	}

	if(g_Joystick->IsButtonDown(0))
//.........这里部分代码省略.........
开发者ID:Nickchooshin,项目名称:THE-DILUVIO,代码行数:101,代码来源:SampleScene.cpp


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