本文整理汇总了C++中EntityBase::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityBase::GetPosition方法的具体用法?C++ EntityBase::GetPosition怎么用?C++ EntityBase::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityBase
的用法示例。
在下文中一共展示了EntityBase::GetPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void GameStateGame::Update(const sf::Time& time)
{
SharedContext* context = m_stateMgr->GetContext();
EntityBase * player = context->entityManager->Find("Player");
if (!player)
{
std::cout << "Respawning player..." << std::endl;
context->entityManager->Add(EntityType::Player, "Player");
player = context->entityManager->Find("Player");
player->SetPosition(m_gameMap->GetPlayerStart());
std::cout << "Player respawned..." << std::endl;
}
else
{
m_view.setCenter(player->GetPosition());
context->window->GetRenderWindow()->setView(m_view);
}
sf::FloatRect viewSpace = context->window->GetViewSpace();
if (viewSpace.left <= 0)
{
m_view.setCenter(viewSpace.width / 2.0f, m_view.getCenter().y);
context->window->GetRenderWindow()->setView(m_view);
}
else if (viewSpace.left + viewSpace.width > (m_gameMap->GetMapSize().x) * TILE_SIZE)
{
m_view.setCenter(((m_gameMap->GetMapSize().x) * TILE_SIZE) - (viewSpace.width / 2.0f),
m_view.getCenter().y);
context->window->GetRenderWindow()->setView(m_view);
}
if (viewSpace.top <= 0)
{
m_view.setCenter(m_view.getCenter().x, viewSpace.height / 2.0f);
context->window->GetRenderWindow()->setView(m_view);
}
else if (viewSpace.top + viewSpace.height >
(m_gameMap->GetMapSize().y) * TILE_SIZE)
{
m_view.setCenter(m_view.getCenter().x,
((m_gameMap->GetMapSize().y) *
TILE_SIZE) - (viewSpace.height / 2.0f));
context->window->GetRenderWindow()->setView(m_view);
}
m_gameMap->Update(time.asSeconds());
m_stateMgr->GetContext()->entityManager->Update(time.asSeconds());
}