Cocos2d x Cocos2dx CCTableView问题
我使用CCTableView制作了一个下拉列表。它工作得很好。现在我必须在选择任何条目时隐藏该表。因此,我编写了以下代码Cocos2d x Cocos2dx CCTableView问题,cocos2d-x,Cocos2d X,我使用CCTableView制作了一个下拉列表。它工作得很好。现在我必须在选择任何条目时隐藏该表。因此,我编写了以下代码 void Sample1::tableCellTouched(CCTableView* table, CCTableViewCell* cell) { CCLOG("cell touched at index: %i", cell->getIdx()); table->setVisible(false); } 当执行此操作时,表格将不
void Sample1::tableCellTouched(CCTableView* table, CCTableViewCell* cell)
{
CCLOG("cell touched at index: %i", cell->getIdx());
table->setVisible(false);
}
当执行此操作时,表格将不可见,但当我再次尝试使其可见时,它(CCTableView)不会响应任何触摸,而其他按钮会响应
有人能猜出哪里出了问题吗 这是因为CCTableView本身会检查是否可见,如果不可见,则不会处理触摸。 这里是CCTableView.cpp中的责任部分:
if (!this->isVisible()) {
return;
}
此代码段位于ccTouchBegind
和ccTouchEnded
中
您的代理的
tableCellTouched
将在CCTableView的ccTouchEnded
中调用,因此您必须使您的表在不依赖于来自CCTableView的调用的函数中可见。用于在CCTable中添加Tablecell
创建一个名为CustomClass的类:
在CustomClass.cpp中
CCTableCell*CustomClass::tableMethod(CCTable*pTable,无符号整数idx)
{
CCTableCell*tableCell=pTable->dequeueCell()
addChild(tableCell)
返回表单元
}
}您是如何将单元格添加到CCTableView的?你能分享吗?
}