当前位置: 首页>>代码示例>>C++>>正文


C++ Entity::AttachComponent方法代码示例

本文整理汇总了C++中Entity::AttachComponent方法的典型用法代码示例。如果您正苦于以下问题:C++ Entity::AttachComponent方法的具体用法?C++ Entity::AttachComponent怎么用?C++ Entity::AttachComponent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Entity的用法示例。


在下文中一共展示了Entity::AttachComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: BuildEntity

//-----------------------------------------------------------------------------------------------
void MissileBlueprint::BuildEntity( Entity& out_entity )
{
	out_entity.typeID = TYPEID_Bullet;

 	MeshComponent* missileMesh = m_game->m_worldRenderingSystem->AcquireMeshComponent();
 	missileMesh->vertexDataIsFlyweight = true;
 	missileMesh->vertexData = &m_vertices;
 	missileMesh->material = m_material;
	out_entity.AttachComponent( missileMesh );

	PhysicsComponent* spacePhysics = m_game->m_physicsSystem->AcquireComponent();
	spacePhysics->percentAcceleratedByGravity = 0.f;
	out_entity.AttachComponent( spacePhysics );

	CollisionComponent2D* missileCollider = m_game->m_collisionSystem->AcquireComponent();
	missileCollider->group = 1;
	missileCollider->SetColliderToCircle( m_colliderCenter, m_colliderRadius );
	out_entity.AttachComponent( missileCollider );

	TimedDestructionComponent* missileFailsafe = m_game->m_timedDestructionSystem->AcquireComponent();
	missileFailsafe->secondsLeftUntilDestruction = 1.f;
	out_entity.AttachComponent( missileFailsafe );

	ScoringComponent* missileScore = m_game->m_scoringSystem->AcquireComponent();
	missileScore->pointValue = 1;
	out_entity.AttachComponent( missileScore );
}
开发者ID:vingenuity,项目名称:meteoroid-game,代码行数:28,代码来源:MissileBlueprint.cpp

示例2: BuildEntityIntoGame

//-----------------------------------------------------------------------------------------------
void ShipBlueprint::BuildEntityIntoGame( Entity& out_entity, const MeteoroidGame* game,
										const FloatVector2& atPosition )
{
	out_entity.typeID = TYPEID_Ship;
	out_entity.position.x = atPosition.x;
	out_entity.position.y = atPosition.y;

	MeshComponent* shipMesh = game->m_worldRenderingSystem->AcquireMeshComponent();
	shipMesh->vertexDataIsFlyweight = true;
	shipMesh->vertexData = &m_vertices;
	shipMesh->material = m_material;
	out_entity.AttachComponent( shipMesh );

	PhysicsComponent* shipPhysics = game->m_physicsSystem->AcquireComponent();
	shipPhysics->percentAcceleratedByGravity = 0.f;
	out_entity.AttachComponent( shipPhysics );

	CollisionComponent2D* shipCollider = game->m_collisionSystem->AcquireComponent();
	shipCollider->group = SHIP_COLLISION_GROUP;
	shipCollider->SetColliderToCircle( m_colliderCenter, m_colliderRadius );
	out_entity.AttachComponent( shipCollider );

	WarpComponent* warpEngine = game->m_warpSystem->AcquireComponent();
	warpEngine->secondsSinceLastWarp = warpEngine->secondsNeededBetweenWarps = 2.f;
	out_entity.AttachComponent( warpEngine );

	WeaponComponent* missilePort = game->m_weaponSystem->AcquireComponent();
	missilePort->firingSound = AudioInterface::GetOrLoadSound( "Audio/laser.wav" );
	missilePort->minSecondsBetweenShots = 0.75f;
	out_entity.AttachComponent( missilePort );
}
开发者ID:vingenuity,项目名称:meteoroid-game,代码行数:32,代码来源:ShipBlueprint.cpp


注:本文中的Entity::AttachComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。