本文整理汇总了C++中Obstacle::Update方法的典型用法代码示例。如果您正苦于以下问题:C++ Obstacle::Update方法的具体用法?C++ Obstacle::Update怎么用?C++ Obstacle::Update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Obstacle
的用法示例。
在下文中一共展示了Obstacle::Update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: First
void sv::ObstacleManager::Update(ulong deltaTime)
{
Iterator iter = First();
while(iter)
{
Obstacle* obstacle = Get(iter);
iter = Next(iter);
obstacle->Update(deltaTime);
if( obstacle->IsEdge() )
HandleCollision(obstacle);
if( obstacle->GetPos() == Grid::InvalidPos )
DeleteObstacle(obstacle);
}
UpdateLevel(deltaTime);
}
示例2: Update
void ObstacleManager::Update(float dt)
{
if (spawnTrashCan)
{
Obstacle *obstacleObj = new Obstacle();
obstacleObj->initWithType(trashCan , 1);
allObstacles->addObject(obstacleObj);
this->addChild(obstacleObj , 2);
spawnTrashCan = false;
}
if (spawnCrow)
{
Obstacle *obstacleObj = new Obstacle();
obstacleObj->initWithType(crow , 1);
allObstacles->addObject(obstacleObj);
this->addChild(obstacleObj , 2);
spawnCrow = false;
}
if (spawnObstaclePattern && !destroyAll)
{
int pattern = 1;
//CCLog("Background is : %d" , currentBg);
if (currentBg == jungleBg)
{
pattern = arc4random() % 2;
pattern = clampf(pattern , 0, 1 );
//CCLog("Jungle Pattern : %d" , pattern + 1);
//CCLog("Jungle Pattern is: %s" , allObstacleChunks[pattern].obstaclePattern.c_str());
GenerateObstaclePattern(jungleObstacles[pattern].obstaclePattern);
currentPatternDistance = jungleObstacles[pattern].patternDistance;
}
else
{
pattern = arc4random() % EASY_CHUNK_COUNT ;
pattern = clampf(pattern , 0, EASY_CHUNK_COUNT);
//pattern = 5;
//pattern = 4;
//CCLog("Pattern : %d" , pattern + 1);
//CCLog("Pattern is: %s" , allObstacleChunks[pattern].obstaclePattern.c_str());
GenerateObstaclePattern(allObstacleChunks[pattern].obstaclePattern);
currentPatternDistance = allObstacleChunks[pattern].patternDistance;
}
patternStartDistance = currentDistance;
spawnObstaclePattern = false;
}
for (unsigned int i = 0 ; i < allObstacles->count() ; i++)
{
Obstacle *obstacleObj = (Obstacle*)allObstacles->objectAtIndex(i);
obstacleObj->Update(dt);
if (obstacleObj->GetRemoveMe())
{
obstaclesToDelete->addObject(obstacleObj);
}
}
for (unsigned int i = 0 ; i < obstaclesToDelete->count() ; i++)
{
Obstacle *obstacleObj = (Obstacle*)obstaclesToDelete->objectAtIndex(i);
allObstacles->removeObject(obstacleObj);
this->removeChild(obstacleObj, false);
obstacleObj->release();
obstacleObj = NULL;
}
obstaclesToDelete->removeAllObjects();
}