本文整理汇总了C++中EntityManager::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ EntityManager::Create方法的具体用法?C++ EntityManager::Create怎么用?C++ EntityManager::Create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::Create方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreatePlayer
GameEntity EntityFactory::CreatePlayer(DirectX::XMFLOAT3 position)
{
EntityManager* pEntity = EntityManager::Instance();
ResourceManager* pResource = ResourceManager::Instance();
GameEntity player = pEntity->Create("Player");
pEntity->AddComponent<RenderComponent>(player, pResource->GetMaterial("ship"), pResource->GetMesh("Ship"));
pEntity->AddComponent<InputComponent>(player, 5.0f);
pEntity->AddComponent<CollisionComponent>(player, *pResource->GetMesh("Ship"), XMFLOAT3(0, 0, 0), 0.0007f);
pEntity->AddComponent<AttackComponent>(player, 5.0f);
TransformComponent* pTrans = pEntity->AddComponent<TransformComponent>(player, position);
pTrans->transform.SetScale(.001f);
PhysicsComponent* pPhysics = pEntity->AddComponent<PhysicsComponent>(player, XMVectorZero(), XMVectorZero());
pPhysics->drag = 0.60f;
pPhysics->rotationalDrag = 0.30f;
GameEntity exhaust = pEntity->Create("Exhaust");
pEntity->AddComponent<RenderComponent>(exhaust, pResource->GetMaterial("thruster"), pResource->GetMesh("Thruster"))->maskOnly = true;
TransformComponent* eTrans = pEntity->AddComponent<TransformComponent>(exhaust, position);
eTrans->transform.Translate(0.0f, 0.0f, -0.3f);
eTrans->transform.Scale(400.0f);
pTrans->transform.AddChild(&eTrans->transform);
// Particles
Particle p(XMFLOAT4(1, 0, 0, 1),
XMFLOAT4(1, 1, 0.1f, 0.8f),
XMFLOAT4(1, 0.5f, 0.1f, 0.9f),
XMFLOAT3(0, 0, -0.9),
XMFLOAT3(0, 0, -0.3),
XMFLOAT3(0, 0, 0),
0.9f,
0.4f,
0.1f,
0.0f,
0);
ParticleGenerator* pGML = new ParticleGenerator(p, XMFLOAT3( 0.0f, -0.16f, -1.05f), 0.08f, 0.00001, 10);
ParticleGenerator* pGMU = new ParticleGenerator(p, XMFLOAT3( 0.0f, +0.04f, -1.05f), 0.08f, 0.00001, 10);
ParticleGenerator* pGRU = new ParticleGenerator(p, XMFLOAT3(+0.33f, +0.04f, -1.05f), 0.08f, 0.00001, 10);
ParticleGenerator* pGLU = new ParticleGenerator(p, XMFLOAT3(-0.33f, +0.04f, -1.05f), 0.08f, 0.00001, 10);
ParticleGenerator* pGRL = new ParticleGenerator(p, XMFLOAT3(+0.35f, -0.16f, -1.05f), 0.08f, 0.00001, 10);
ParticleGenerator* pGLL = new ParticleGenerator(p, XMFLOAT3(-0.35f, -0.16f, -1.05f), 0.08f, 0.00001, 10);
ParticleComponent* pParticles = pEntity->AddComponent<ParticleComponent>(player);
pParticles->AddGenerator(pGML);
pParticles->AddGenerator(pGMU);
pParticles->AddGenerator(pGRU);
pParticles->AddGenerator(pGLU);
pParticles->AddGenerator(pGRL);
pParticles->AddGenerator(pGLL);
return player;
}
示例2: CreateTextField
GameEntity EntityFactory::CreateTextField(std::wstring text, std::string spritefont_id, DirectX::XMFLOAT2 position, DirectX::XMFLOAT4 color)
{
EntityManager* pEntity = EntityManager::Instance();
ResourceManager* pResource = ResourceManager::Instance();
GameEntity textfield = pEntity->Create("Text");
pEntity->AddComponent<UITextComponent>(textfield, text, spritefont_id, position, color);
return textfield;
}
示例3: CreateButton
GameEntity EntityFactory::CreateButton(DirectX::XMFLOAT2 center, float width, float height, std::string event, std::wstring text, std::string spritefont_id, DirectX::XMFLOAT2 position, DirectX::XMFLOAT4 color)
{
EntityManager* pEntity = EntityManager::Instance();
ResourceManager* pResource = ResourceManager::Instance();
float halfWidth = static_cast<float>(pResource->GetWindowWidth()) / 2.0f;
float halfHeight = static_cast<float>(pResource->GetWindowHeight()) / 2.0f;
GameEntity button = pEntity->Create("Button");
pEntity->AddComponent<ButtonComponent>(button, true, event);
pEntity->AddComponent<AABBComponent>(button, XMFLOAT2{center.x + halfWidth, center.y + halfHeight}, width / 2.0f, height / 2.0f);
pEntity->AddComponent<UITextComponent>(button, text, spritefont_id, position, color);
return button;
}
示例4: CreatePointLight
GameEntity EntityFactory::CreatePointLight(DirectX::XMFLOAT4 color, DirectX::XMFLOAT3 position, float specularExponent)
{
EntityManager* pEntity = EntityManager::Instance();
GameEntity pointLight = pEntity->Create("PointLight");
pEntity->AddComponent<PointLightComponent>
(
pointLight,
color,
position,
specularExponent
);
return pointLight;
}
示例5: CreateDirectionalLight
GameEntity EntityFactory::CreateDirectionalLight(DirectX::XMFLOAT4 color, DirectX::XMFLOAT3 direction, float specularExponent)
{
EntityManager* pEntity = EntityManager::Instance();
GameEntity dirLight = pEntity->Create("DirectionalLight");
pEntity->AddComponent<DirectionalLightComponent>
(
dirLight,
color,
direction,
specularExponent
);
return dirLight;
}
示例6: CreateAsteroid
GameEntity EntityFactory::CreateAsteroid(DirectX::XMFLOAT3 position, DirectX::XMFLOAT3 velocity, DirectX::XMFLOAT3 acceleration, DirectX::XMFLOAT3 rotation, float scale, int id)
{
EntityManager* pEntity = EntityManager::Instance();
ResourceManager* pResource = ResourceManager::Instance();
GameEntity asteroid = pEntity->Create("Asteroid");
pEntity->AddComponent<CollisionComponent>(asteroid, 0.95f*scale, position);
pEntity->AddComponent<AsteroidRenderComponent>(asteroid, id);
pEntity->AddComponent<RenderComponent>(asteroid, pResource->GetMaterial("asteroid"), pResource->GetMesh("Sphere"));
pEntity->AddComponent<PhysicsComponent>(asteroid, velocity, acceleration);
TransformComponent* pTransform = pEntity->AddComponent<TransformComponent>(asteroid, position);
pTransform->transform.SetRotation(rotation);
pTransform->transform.SetScale(scale);
return asteroid;
}
示例7: CreateSpotlight
GameEntity EntityFactory::CreateSpotlight(DirectX::XMFLOAT4 color, DirectX::XMFLOAT3 position, DirectX::XMFLOAT3 direction, float specularExponent, float spotlightPower)
{
EntityManager* pEntity = EntityManager::Instance();
GameEntity spotlight = pEntity->Create("SpotLight");
pEntity->AddComponent<SpotLightComponent>
(
spotlight,
color,
position,
direction,
specularExponent,
spotlightPower
);
return spotlight;
}