<img title = '1.jpg' src='http://cdn.cocimg.com/bbs/attachment/Fid_41/41_241554_5880a5b3f69fad3.jpg' >
我想做个列表点下的效果。也就是说有个点到那一列,哪一列的背景图就改变。但是问题来
void CQuestLayer_cl::tableCellTouched( CCTableView* table, CCTableViewCell* cell )
{
CCTexture2D* ptexture;
for ( int i = 0; i < ( int )m_pCellArray->count(); ++i )
{
CCTableViewCell* pCell = ( CCTableViewCell* )m_pCellArray->objectAtIndex( i );
if ( pCell->getIdx() == cell->getIdx() )
{
ptexture = CCTextureCache::sharedTextureCache()->addImage( “Quest/Quest_ChildBoxDown.png” );
( ( CCSprite* )cell->getChildByTag( ChildBoxTAG ) )->setTexture( ptexture );
CCLog( " if %d", pCell->getIdx() );
}
else
{
ptexture = CCTextureCache::sharedTextureCache()->addImage( “Quest/Quest_ChildBoxUp.png” );
( ( CCSprite* )pCell->getChildByTag( ChildBoxTAG ) )->setTexture( ptexture );
CCLog( " else %d", pCell->getIdx() );
}
}
CCLog(“cell touched at index: %i”, cell->getIdx());
}
我在抬起的时候判断的。比如我点的下标是0的格子。那么0, 8, 16 都会改变了状态。 点1就是 1, 9, 17 每隔8个都会显示被点下的状态。这是为什么? 之前用CCTableview没做过点击状态的所以这次感觉很坑爹。求大神解释下!!!!
CCTableViewCell* CQuestLayer_cl::tableCellAtIndex( CCTableView *table, unsigned int idx ) 最后这个里面椀搀砀 断点看的时候顺序是乱的! 总数20个 从13开始的 到20之后又从0开始 这是为什么!