本文整理汇总了C++中Planet::SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ Planet::SetProperty方法的具体用法?C++ Planet::SetProperty怎么用?C++ Planet::SetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Planet
的用法示例。
在下文中一共展示了Planet::SetProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GeneratePlanet
ATHObject* ObjectGenerator::GeneratePlanet(float2 _fPos, float _fMinRadius, float _fMaxRadius, float3 _fColor)
{
// The new Object
Planet* pNewObject = new Planet();
// Decide stats
int nSlotCount = GetNextPlanetSlotCount();
pNewObject->SetProperty("structure-slot-count", &nSlotCount, APT_INT);
float fPlanetRadius = PLANET_SLOT_LENGTH / (2.0f * sin(3.141592f / nSlotCount));
pNewObject->SetProperty("radius", &fPlanetRadius, APT_FLOAT);
// Set the mass
float fDensity = 1.0f;
float fArea = b2_pi * fPlanetRadius * fPlanetRadius;
pNewObject->SetMass(fArea * fDensity);
// Create the b2Body
b2BodyDef bodyDef;
bodyDef.position = b2Vec2(_fPos.vX, _fPos.vY);
bodyDef.type = b2_kinematicBody;
b2Body* pPlanetBody = m_pObjectManager->m_pWorld->CreateBody(&bodyDef);
// Create the planet fixture
b2FixtureDef fixtureDef;
b2CircleShape planetCircleShape;
planetCircleShape.m_radius = fPlanetRadius;
fixtureDef.shape = &planetCircleShape;
pPlanetBody->CreateFixture(&fixtureDef);
// Create the gravity sensor
planetCircleShape.m_radius = fPlanetRadius * 5.0f;
fixtureDef.shape = &planetCircleShape;
fixtureDef.isSensor = true;
pPlanetBody->CreateFixture(&fixtureDef);
pNewObject->SetProperty("gravity-radius", &planetCircleShape.m_radius, APT_FLOAT);
// Create the image
ATHRenderNode* pRenderNode = GeneratePlanetTexture(_fColor, fPlanetRadius);
// Init the game object
pNewObject->Init(pRenderNode, pPlanetBody);
m_pObjectManager->AddObject(pNewObject);
return pNewObject;
}