本文整理汇总了C++中Projectile::initProjectile方法的典型用法代码示例。如果您正苦于以下问题:C++ Projectile::initProjectile方法的具体用法?C++ Projectile::initProjectile怎么用?C++ Projectile::initProjectile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projectile
的用法示例。
在下文中一共展示了Projectile::initProjectile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createProjectile
Projectile* Projectile::createProjectile(string filename, Vec2 p, Vec2 speed, string name)
{
Projectile* ob = new Projectile();
if(ob && ob->initProjectile(filename, p, speed, name))
{
ob->autorelease();
return ob;
}
CC_SAFE_DELETE(ob);
return NULL;
}
示例2: shoot
void Turret::shoot (bool playerControlled, Player* targetPlayer)
{
if (data && data->isSustained == false) {
if (data && data->projectile.type == -1)
{
if (!isGhost())
if (const char* script = scriptName("onFire"))
Console->executef(2, script, scriptThis());
}
else
{
float energy = getEnergy();
if (waitTime <= manager->getCurrentTime() && data && energy >= data->minGunEnergy && data->projectile.type != -1)
{
TMat3F muzzleTransform;
getMuzzleTransform(0, &muzzleTransform);
Projectile* bullet = createProjectile(data->projectile);
if (!playerControlled && data->deflection)
{
static Random random;
EulerF angles;
muzzleTransform.angles (&angles);
angles.x += (random.getFloat() - 0.5) * M_2PI * data->deflection;
angles.z += (random.getFloat() - 0.5) * M_2PI * data->deflection;
muzzleTransform.set (angles, muzzleTransform.p);
}
else
if (playerControlled)
{
Point3F start = muzzleTransform.p;
muzzleTransform = getEyeTransform ();
aimedTransform (&muzzleTransform, start);
muzzleTransform.p = start;
}
bullet->initProjectile (muzzleTransform, Point3F (0, 0, 0), getId());
if (bullet->isTargetable() == true) {
if (targetPlayer != NULL) {
if (GameBase* mo = targetPlayer->getMountObject())
bullet->setTarget(static_cast<ShapeBase*>(mo));
else
bullet->setTarget(targetPlayer);
} else if (playerControlled) {
ShapeBase* pClosest = NULL;
Point3F closeHisPos;
float closestVal = -2.0f;
SimSet::iterator itr;
Point3F lookDir;
getEyeTransform().getRow(1, &lookDir);
lookDir.normalize();
SimContainerQuery collisionQuery;
SimCollisionInfo info;
collisionQuery.id = getId();
collisionQuery.type = -1;
collisionQuery.mask = Projectile::csm_collisionMask;
collisionQuery.detail = SimContainerQuery::DefaultDetail;
collisionQuery.box.fMin = getEyeTransform().p;
SimContainer* pRoot = (SimContainer*)manager->findObject(SimRootContainerId);
SimSet* pSet = dynamic_cast<SimSet*>(manager->findObject(PlayerSetId));
AssertFatal(pSet != NULL, "No player set?");
for (itr = pSet->begin(); itr != pSet->end(); itr++) {
Player* pPlayer = dynamic_cast<Player*>(*itr);
if (!pPlayer || pPlayer->getVisibleToTeam(getTeam()) == false)
continue;
collisionQuery.box.fMax = pPlayer->getBoxCenter();
if (pRoot->findLOS(collisionQuery, &info, SimCollisionImageQuery::High) == true) {
if (info.object != (SimObject*)pPlayer)
continue;
}
Point3F hisPos = pPlayer->getBoxCenter();
hisPos -= getLinearPosition();
hisPos.normalize();
float prod = m_dot(hisPos, lookDir);
if (prod > 0.0f && prod > closestVal) {
closestVal = prod;
pClosest = pPlayer;
closeHisPos = hisPos;
}
}
pSet = dynamic_cast<SimSet*>(manager->findObject(MoveableSetId));
AssertFatal(pSet != NULL, "No moveable set?");
for (itr = pSet->begin(); itr != pSet->end(); itr++) {
if (((*itr)->getType() & VehicleObjectType) == 0)
continue;
ShapeBase* pObject = dynamic_cast<ShapeBase*>(*itr);
if (pObject->getVisibleToTeam(getTeam()) == false)
continue;
//.........这里部分代码省略.........