本文整理汇总了C++中CSprite::PlayAnimation方法的典型用法代码示例。如果您正苦于以下问题:C++ CSprite::PlayAnimation方法的具体用法?C++ CSprite::PlayAnimation怎么用?C++ CSprite::PlayAnimation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSprite
的用法示例。
在下文中一共展示了CSprite::PlayAnimation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Init
// Initializare
void Init(CSprite *spr)
{
m_Sprite = spr;
glm::vec3 pz = m_Sprite->GetPosition();
m_Sprite->PlayAnimation("BugEye_Idle");
}
示例2: 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;
}
//.........这里部分代码省略.........