本文整理汇总了C++中SmartPtr::GetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ SmartPtr::GetPosition方法的具体用法?C++ SmartPtr::GetPosition怎么用?C++ SmartPtr::GetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SmartPtr
的用法示例。
在下文中一共展示了SmartPtr::GetPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Sprite
SmartPtr<GameObject> Asteroids::CreateAsteroidOre(int _x, int _y)
{
Animation *anim_ptr = AnimationManager::GetInstance().GetAnimationByName("asteroidOre1");
SmartPtr<Sprite> asteroidOre_sprite = new Sprite(anim_ptr->GetWidth(), anim_ptr->GetHeight(), anim_ptr);
asteroidOre_sprite->SetLoopAnimation(true);
SmartPtr<GameObject> asteroidOre = new AsteroidOre(_x, _y);
asteroidOre->SetSprite(asteroidOre_sprite);
asteroidOre->SetScale(0.2f);
//debug
if(mConsoleDebug == true) cout << "Created an Ore asteroid: " << asteroidOre->GetPosition().x << "," << asteroidOre->GetPosition().y << endl;
return asteroidOre;
}
示例2: OnObjectRemoved
void Asteroids::OnObjectRemoved(GameWorld* world, SmartPtr<GameObject> object)
{
if (object->GetType() == GameObjectType("Asteroid"))
{
SmartPtr<GameObject> explosion = CreateExplosion();
explosion->SetPosition(object->GetPosition());
explosion->SetRotation(object->GetRotation());
mGameWorld->AddObject(explosion);
mAsteroidCount--;
if(object->GetScale() > 0.2) {
float newVel[4][2] = { {-1.0,-1.0}, { 1.0,-1.0},
{ 1.0, 1.0}, {-1.0, 1.0} };
GLVector3f obPos = object->GetPosition();
for(int i = 0; i < 4; i++)
{
SmartPtr<GameObject> newAsteroid = CreateAsteroid(obPos.x, obPos.y);
float f = 5; //force
newAsteroid->SetVelocity(GLVector3f(newVel[i][0] * f + (rand() % 4), newVel[i][1] * f + (rand() % 4), 0.0));
newAsteroid->SetScale(object->GetScale()/2);
mGameWorld->AddObject(newAsteroid);
mAsteroidCount++;
}
}
if (mAsteroidCount <= 0)
{
SetTimer(500, START_NEXT_LEVEL);
}
}
if (object->GetType() == GameObjectType("AsteroidOre"))
{
SmartPtr<GameObject> explosion = CreateExplosion();
explosion->SetPosition(object->GetPosition());
explosion->SetRotation(object->GetRotation());
mGameWorld->AddObject(explosion);
float newPos[4][2] = { {-1.0,-1.0}, { 1.0,-1.0},
{ 1.0, 1.0}, {-1.0, 1.0} };
GLVector3f obPos = object->GetPosition();
float obRot = object->GetRotation();
int sep = 5; // how much to separate the ore fromt he position of the asteroid
for(int i = 0; i < 4; i++)
{
SmartPtr<GameObject> ore = CreateOre();
ore->SetPosition(GLVector3f(obPos.x + newPos[i][0] * sep + (rand() % 4), obPos.y + newPos[i][1] * sep + (rand() % 4), 0.0));
ore->SetRotation(obRot);
mGameWorld->AddObject(ore);
}
int noA = 1 + (rand() % 3);
cout << "RAND A: " << noA << endl;
for (int i = 0; i < noA; i++)
{
SmartPtr<GameObject> newAsteroid = CreateAsteroid(obPos.x, obPos.y);
float rA = rand() % 360; // a random angle
cout << "RAND ANGLE: " << rA << endl;
newAsteroid->SetVelocity(GLVector3f( cos(DEG2RAD * rA), sin(DEG2RAD * rA), 0.0));
cout << "Object Scale: " << object->GetScale() << endl;
newAsteroid->SetScale(object->GetScale());
mGameWorld->AddObject(newAsteroid);
mAsteroidCount++;
}
}
}