本文整理汇总了C++中SoccerWorld::setLastKartTohitBall方法的典型用法代码示例。如果您正苦于以下问题:C++ SoccerWorld::setLastKartTohitBall方法的具体用法?C++ SoccerWorld::setLastKartTohitBall怎么用?C++ SoccerWorld::setLastKartTohitBall使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SoccerWorld
的用法示例。
在下文中一共展示了SoccerWorld::setLastKartTohitBall方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
/** Updates the physics simulation and handles all collisions.
* \param dt Time step.
*/
void Physics::update(float dt)
{
PROFILER_PUSH_CPU_MARKER("Physics", 0, 0, 0);
m_physics_loop_active = true;
// Bullet can report the same collision more than once (up to 4
// contact points per collision). Additionally, more than one internal
// substep might be taken, resulting in potentially even more
// duplicates. To handle this, all collisions (i.e. pair of objects)
// are stored in a vector, but only one entry per collision pair
// of objects.
m_all_collisions.clear();
// Maximum of three substeps. This will work for framerate down to
// 20 FPS (bullet default frequency is 60 HZ).
m_dynamics_world->stepSimulation(dt, 3);
// Now handle the actual collision. Note: flyables can not be removed
// inside of this loop, since the same flyables might hit more than one
// other object. So only a flag is set in the flyables, the actual
// clean up is then done later in the projectile manager.
std::vector<CollisionPair>::iterator p;
for(p=m_all_collisions.begin(); p!=m_all_collisions.end(); ++p)
{
// Kart-kart collision
// --------------------
if(p->getUserPointer(0)->is(UserPointer::UP_KART))
{
KartKartCollision(p->getUserPointer(0)->getPointerKart(),
p->getContactPointCS(0),
p->getUserPointer(1)->getPointerKart(),
p->getContactPointCS(1) );
continue;
} // if kart-kart collision
if(p->getUserPointer(0)->is(UserPointer::UP_PHYSICAL_OBJECT))
{
// Kart hits physical object
// -------------------------
PhysicalObject *obj = p->getUserPointer(0)
->getPointerPhysicalObject();
if(obj->isCrashReset())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
new RescueAnimation(kart);
}
else if (obj->isExplodeKartObject())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
ExplosionAnimation::create(kart);
}
else if (obj->isFlattenKartObject())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
const KartProperties* kp = kart->getKartProperties();
kart->setSquash(kp->getSquashDuration(), kp->getSquashSlowdown());
}
else if(obj->isSoccerBall())
{
int kartId = p->getUserPointer(1)->getPointerKart()->getWorldKartId();
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
soccerWorld->setLastKartTohitBall(kartId);
}
continue;
}
if(p->getUserPointer(0)->is(UserPointer::UP_ANIMATION))
{
// Kart hits animation
ThreeDAnimation *anim=p->getUserPointer(0)->getPointerAnimation();
if(anim->isCrashReset())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
new RescueAnimation(kart);
}
else if (anim->isExplodeKartObject())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
ExplosionAnimation::create(kart);
}
else if (anim->isFlattenKartObject())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
const KartProperties* kp = kart->getKartProperties();
kart->setSquash(kp->getSquashDuration(), kp->getSquashSlowdown());
}
continue;
}
// now the first object must be a projectile
// =========================================
if(p->getUserPointer(1)->is(UserPointer::UP_TRACK))
{
// Projectile hits track
// ---------------------
p->getUserPointer(0)->getPointerFlyable()->hitTrack();
}
//.........这里部分代码省略.........
示例2: update
/** Updates the physics simulation and handles all collisions.
* \param dt Time step.
*/
void Physics::update(float dt)
{
PROFILER_PUSH_CPU_MARKER("Physics", 0, 0, 0);
m_physics_loop_active = true;
// Bullet can report the same collision more than once (up to 4
// contact points per collision). Additionally, more than one internal
// substep might be taken, resulting in potentially even more
// duplicates. To handle this, all collisions (i.e. pair of objects)
// are stored in a vector, but only one entry per collision pair
// of objects.
m_all_collisions.clear();
// Maximum of three substeps. This will work for framerate down to
// 20 FPS (bullet default frequency is 60 HZ).
m_dynamics_world->stepSimulation(dt, 3);
// Now handle the actual collision. Note: flyables can not be removed
// inside of this loop, since the same flyables might hit more than one
// other object. So only a flag is set in the flyables, the actual
// clean up is then done later in the projectile manager.
std::vector<CollisionPair>::iterator p;
for(p=m_all_collisions.begin(); p!=m_all_collisions.end(); ++p)
{
// Kart-kart collision
// --------------------
if(p->getUserPointer(0)->is(UserPointer::UP_KART))
{
KartKartCollision(p->getUserPointer(0)->getPointerKart(),
p->getContactPointCS(0),
p->getUserPointer(1)->getPointerKart(),
p->getContactPointCS(1) );
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
int kartid1 = p->getUserPointer(0)->getPointerKart()->getWorldKartId();
int kartid2 = p->getUserPointer(1)->getPointerKart()->getWorldKartId();
script_engine->runFunction("void onKartKartCollision(int, int)",
[=](asIScriptContext* ctx) {
ctx->SetArgDWord(0, kartid1);
ctx->SetArgDWord(1, kartid2);
});
continue;
} // if kart-kart collision
if(p->getUserPointer(0)->is(UserPointer::UP_PHYSICAL_OBJECT))
{
// Kart hits physical object
// -------------------------
Scripting::ScriptEngine* script_engine = World::getWorld()->getScriptEngine();
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
int kartId = kart->getWorldKartId();
PhysicalObject* obj = p->getUserPointer(0)->getPointerPhysicalObject();
std::string obj_id = obj->getID();
std::string scripting_function = obj->getOnKartCollisionFunction();
if (scripting_function.size() > 0)
{
script_engine->runFunction("void " + scripting_function + "(int, const string)",
[&](asIScriptContext* ctx) {
ctx->SetArgDWord(0, kartId);
ctx->SetArgObject(1, &obj_id);
});
}
if (obj->isCrashReset())
{
new RescueAnimation(kart);
}
else if (obj->isExplodeKartObject())
{
ExplosionAnimation::create(kart);
}
else if (obj->isFlattenKartObject())
{
const KartProperties* kp = kart->getKartProperties();
kart->setSquash(kp->getSquashDuration() * kart->getPlayerDifficulty()->getSquashDuration(),
kp->getSquashSlowdown() * kart->getPlayerDifficulty()->getSquashSlowdown());
}
else if(obj->isSoccerBall() &&
race_manager->getMinorMode() == RaceManager::MINOR_MODE_SOCCER)
{
SoccerWorld* soccerWorld = (SoccerWorld*)World::getWorld();
soccerWorld->setLastKartTohitBall(kartId);
}
continue;
}
if (p->getUserPointer(0)->is(UserPointer::UP_ANIMATION))
{
// Kart hits animation
ThreeDAnimation *anim=p->getUserPointer(0)->getPointerAnimation();
if(anim->isCrashReset())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
new RescueAnimation(kart);
}
else if (anim->isExplodeKartObject())
{
AbstractKart *kart = p->getUserPointer(1)->getPointerKart();
ExplosionAnimation::create(kart);
//.........这里部分代码省略.........