当前位置: 首页>>代码示例>>C++>>正文


C++ Obstacle::Update方法代码示例

本文整理汇总了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);
}
开发者ID:morozd,项目名称:neurron,代码行数:17,代码来源:ObstacleManager.cpp

示例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();
}
开发者ID:jojizaidi,项目名称:Gnome,代码行数:77,代码来源:ObstacleManager.cpp


注:本文中的Obstacle::Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。