本文整理汇总了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 ) );
}
}
示例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 );
}