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


C++ AStarNode::isActive方法代码示例

本文整理汇总了C++中AStarNode::isActive方法的典型用法代码示例。如果您正苦于以下问题:C++ AStarNode::isActive方法的具体用法?C++ AStarNode::isActive怎么用?C++ AStarNode::isActive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AStarNode的用法示例。


在下文中一共展示了AStarNode::isActive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

/// Flip a node when touched 
KDvoid Ch7_GridPathfinding::flipNodeWithTouchedNode ( const CCPoint& tPoint )
{
	KDint	x = (KDint) tPoint.x;
	KDint	y = (KDint) tPoint.y;
	
	if ( x == 0 && y == 0 )
	{
		return;
	}
	if ( x == m_tGridSize.x - 1 && y == m_tGridSize.y - 1 )
	{
		return;
	}
	
	if ( x < 0 || y < 0 || x > m_tGridSize.x - 1 || y > m_tGridSize.y - 1 )
	{
		return;
	}
	
	AStarNode*		pNode = (AStarNode*) ( (CCArray*) m_pGrid->objectAtIndex ( x ) )->objectAtIndex ( y );
	CCSprite*		pSprite = (CCSprite*) m_pSprites->objectForKey ( ccszf ( "(%d,%d)", x, y ) );
	
	if ( pNode->isActive ( ) && m_bAddMode )
	{
		// Remove node as neighbor and vice versa
		pNode->setActive ( KD_FALSE );
		pSprite->setColor ( ccc3 ( 100, 100, 100 ) );
	}
	else if ( !m_bAddMode )
	{
		pNode->setActive ( KD_TRUE );
		// Change sprite color
		pSprite->setColor ( ccc3 ( 200, 200, 200 ) );
	}
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:36,代码来源:Ch7_GridPathfinding.cpp

示例2: CCDictionary

/// Add sprites which correspond to grid nodes 
KDvoid Ch7_GridPathfinding::addGridArt ( KDvoid )
{	
	m_pSprites = new CCDictionary ( );

	for ( KDint x = 0; x < (KDint) m_tGridSize.x; x++ )
	{
		for ( KDint y = 0; y < (KDint) m_tGridSize.y; y++ )
		{
			AStarNode*	pNode = (AStarNode*) ( (CCArray*) m_pGrid->objectAtIndex ( x ) )->objectAtIndex ( y );

			CCSprite*	pSprite = CCSprite::create ( "gridNode.png" );
			pSprite->setPosition ( pNode->getPosition ( ) );
			if ( pNode->isActive ( ) )
			{
				pSprite->setColor ( ccc3 ( 200, 200, 200 ) );
			}
			else
			{
				pSprite->setColor ( ccc3 ( 100, 100, 100 ) );
			}
			m_pGridNode->addChild ( pSprite );
			m_pSprites->setObject ( pSprite, ccszf ( "(%d,%d)", x, y ) );
		}
	}
	
	// Add start point at (0,0)
	CCSprite*	pStartSprite =  CCSprite::create ( "start_button.png" );
	pStartSprite->setPosition ( ccp ( m_tStartCoord.x * m_fNodeSpace + m_fNodeSpace / 2, m_tStartCoord.y * m_fNodeSpace + m_fNodeSpace / 2 ) );
	m_pGridNode->addChild ( pStartSprite );
	
	// Add end point at (gridSize.x-1,gridSize.y-1)
	CCSprite*	pEndSprite =  CCSprite::create ( "end_button.png" );
	pEndSprite->setPosition ( ccp ( m_tEndCoord.x * m_fNodeSpace + m_fNodeSpace / 2, m_tEndCoord.y * m_fNodeSpace + m_fNodeSpace / 2 ) );
	m_pGridNode->addChild ( pEndSprite );
}
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:36,代码来源:Ch7_GridPathfinding.cpp


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