本文整理汇总了C++中ObjectRef::GetPos方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectRef::GetPos方法的具体用法?C++ ObjectRef::GetPos怎么用?C++ ObjectRef::GetPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectRef
的用法示例。
在下文中一共展示了ObjectRef::GetPos方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cast
void Daggerstorm::Cast(ObjectRef user, ObjectRef enemy)
{
for (int i = 0; i < 8; i++) {
auto projectileObject = Object::Create();
projectileObject->SetJustEnabled();
static int projectileNumber = 0;
std::string name = std::string("projectile") + std::to_string(projectileNumber++);
projectileObject->SetName(name);
auto projectileComp = projectileObject->AddComponent<ProjectileComponent>();
auto spriteComp = projectileObject->AddComponent<SpriteComponent>();
auto colliderComp = projectileObject->AddComponent<ColliderComponent>();
Vector2f direction = directions[i];
projectileComp->SetDirection(direction);
projectileComp->SetSpeed(projectileSpeed);
projectileComp->SetSpell(this);
projectileComp->SetUser(user);
projectileComp->SetCanApplyOnUser(false);
spriteComp->SetTexture("dagger.png");
spriteComp->SetSize(Vector2f(20, 40));
colliderComp->InitShape("rectangle", "20, 20");
colliderComp->SetIsStatic(false);
colliderComp->SetIsPhantom(true);
Vector2f userPos = user->GetComponent<SpriteComponent>()->GetSize();
Vector2f startingPos = user->GetPos() + userPos/2.f;
Vector2f projectileSize = spriteComp->GetSize();
float magic = (sqrt(pow(projectileSize.x, 2) + pow(projectileSize.y, 2))) / 2;
projectileObject->SetPos(startingPos +
magic * direction);
g_menuHandler->GetCurrentMenu()->AddChild(std::move(projectileObject));
}
r_cooldown = cooldown;
}