本文整理汇总了C++中PhysicsWorld::setUpdateRate方法的典型用法代码示例。如果您正苦于以下问题:C++ PhysicsWorld::setUpdateRate方法的具体用法?C++ PhysicsWorld::setUpdateRate怎么用?C++ PhysicsWorld::setUpdateRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhysicsWorld
的用法示例。
在下文中一共展示了PhysicsWorld::setUpdateRate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: playBlastAnim
void PlygonDrawer::playBlastAnim(Point2i pos, enNodeColor color)
{
auto convt = m_graph->m_coordCvt;
Vec2 coord = convt.getCoord(pos);
auto scene = Director::getInstance()->getRunningScene();
PhysicsWorld* phyWld = scene->getPhysicsWorld();
for (int i = 0; i < 5; ++i)
{
Sprite* spStar = BeadFactory::createBlastStar(color, 0.2 + 0.1 * i);
float radius = spStar->getContentSize().width/2 * spStar->getScaleX();
spStar->retain();
spStar->setPosition(coord);
/*spStar->runAction( Sequence::createWithTwoActions(MoveBy::create(2.0f, dir),
CallFunc::create([=]() {
spStar->removeFromParent();
spStar->release();
})));*/
spStar->runAction( Sequence::createWithTwoActions(DelayTime::create(15.0f),
CallFunc::create([=]() {
spStar->removeFromParent();
spStar->release();
})));
#define GravityAmpl 50
PhysicsMaterial phyMat = PHYSICSBODY_MATERIAL_DEFAULT; phyMat.density = 200.0f;
auto body = PhysicsBody::createCircle(radius, phyMat);
Vec2 dir = ccp(rand()%100 - 50, rand()%100 - 50);
dir.normalize(); dir = dir * body->getMass() * 8.0f * GravityAmpl;
Vect force(dir);
body->applyImpulse(force);
body->setDynamic(true);
//body->setCategoryBitmask(0x04);
//body->setCollisionBitmask(0x08);
body->setGroup(-1);
body->setGravityEnable(true);
spStar->setPhysicsBody(body);
m_tileMap->addChild(spStar, 100);
}
static bool isPhyInit = false;
if (! isPhyInit) {
isPhyInit = true;
phyWld->setGravity(Vect(0.0f, -9.8f * GravityAmpl));
//phyWld->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL);
phyWld->setUpdateRate(2.5f);
}
}