本文整理汇总了C++中TransformComponent::getScale方法的典型用法代码示例。如果您正苦于以下问题:C++ TransformComponent::getScale方法的具体用法?C++ TransformComponent::getScale怎么用?C++ TransformComponent::getScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TransformComponent
的用法示例。
在下文中一共展示了TransformComponent::getScale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EventListener
void FieldSystem::EventListener(IEvent* eventData)
{
if(MousePositionEvent* event = dynamic_cast<MousePositionEvent*>(eventData))
{
glm::ivec2 mousePos = event->getMousePosition();
m_pickedField = nullptr;
//Simple mouse picking for field
for(std::map<unsigned int, BaseComponent*>::iterator it = m_fieldComponents->begin(); it != m_fieldComponents->end(); ++it)
{
FieldComponent* fieldComp = static_cast<FieldComponent*>(it->second);
unsigned int entityId = fieldComp->getEntityId();
TransformComponent* transformComp = static_cast<TransformComponent*>((*m_transformComponents)[entityId]);
SpriteComponent* spriteComp = static_cast<SpriteComponent*>((*m_spriteComponents)[entityId]);
glm::vec4 bounds = glm::vec4(transformComp->getPosition().x * transformComp->getScale().x, transformComp->getPosition().y * transformComp->getScale().y, spriteComp->getTextureBounds().z * transformComp->getScale().x, spriteComp->getTextureBounds().w * transformComp->getScale().y);
bool isPickedField = m_pickedField == nullptr && fieldComp->getIsPassable() && mousePos.x > bounds.x && mousePos.x < bounds.x + bounds.z && mousePos.y > bounds.y && mousePos.y < bounds.y + bounds.w;
//Either showing start or goal to set
switch(m_gameMode)
{
case MODE_CHOOSE_START:
if(isPickedField)
{
fieldComp->setIsStart(true);
m_pickedField = fieldComp;
}
else
{
fieldComp->setIsStart(false);
}
break;
case MODE_CHOOSE_GOAL:
if(isPickedField)
{
fieldComp->setIsGoal(true);
m_pickedField = fieldComp;
}
else
{
fieldComp->setIsGoal(false);
}
break;
case MODE_DONE:
if (isPickedField)
{
m_pickedField = fieldComp;
}
break;
default:
break;
}
}
RecalculateColors();
}
else if(MouseClickEvent* event = dynamic_cast<MouseClickEvent*>(eventData))
{
if (event->getButton() == sf::Mouse::Button::Left)
{
//Take enemy step/reculculate path or set start/goal
if (m_gameMode == MODE_DONE)
{
m_eventManager->FireEvent<StepEvent>(new StepEvent());
UpdatePheromones();
RecalculateColors();
}
else
{
if (m_pickedField != nullptr)
{
switch (m_gameMode)
{
case MODE_CHOOSE_START:
m_eventManager->FireEvent<StartSetEvent>(new StartSetEvent(m_pickedField));
std::cout << "Start set" << std::endl;
m_eventManager->FireEvent<ShowMessageEvent>(new ShowMessageEvent("Please choose a goal point."));
m_gameMode = MODE_CHOOSE_GOAL;
break;
case MODE_CHOOSE_GOAL:
m_eventManager->FireEvent<GoalSetEvent>(new GoalSetEvent(m_pickedField));
std::cout << "Goal set" << std::endl;
m_eventManager->FireEvent<ShowMessageEvent>(new ShowMessageEvent("Press mouse button for simulation step or 'A' for automatic mode."));
m_gameMode = MODE_DONE;
break;
default:
break;
}
}
}
}
else if (event->getButton() == sf::Mouse::Button::Right)
{
if (m_pickedField != nullptr)
{
m_pickedField->setIsPassable(!m_pickedField->getIsPassable());
m_pickedField->setCurrentPheromoneStrength(0);
m_pickedField->setNewPheromoneStrength(0);
RecalculateColors();
//.........这里部分代码省略.........