首页 > 其他 > 详细

cocos2dx中的一些坑

时间:2014-11-22 20:07:29      阅读:285      评论:0      收藏:0      [点我收藏+]

1、CCTableView中的lua绑定
LUA_TableViewDataSource

在TestLua里有例子,有个TableView的例子
function TableViewTestLayer.cellSizeForTable(table,idx) 

  return 60,60
end

结合下面的C++代码发现第一个是width,第二是height

virtual CCSize tableCellSizeForIndex(CCTableView *table, unsigned int idx)
{
if (NULL != table )
{
int nHandler = table->getScriptHandler(CCTableView::kTableCellSizeForIndex);
if (0 != nHandler)
{
CCArray* resultArray = CCArray::create();
if (NULL != resultArray)
{
CCLuaEngine::defaultEngine()->executeTableViewEvent(CCTableView::kTableCellSizeForIndex, table,&idx,resultArray);
CCAssert(resultArray->count() == 2, "tableCellSizeForIndex Array count error");
CCDouble* width = dynamic_cast<CCDouble*>(resultArray->objectAtIndex(0));
CCDouble* height = dynamic_cast<CCDouble*>(resultArray->objectAtIndex(1));
if (NULL != width && NULL != height)
{
return CCSizeMake((float)width->getValue(), (float)height->getValue());
}
}
}
}

return CCSizeMake(0,0);
}

2、获取点击的sender

点击时发送的sender没有传回,可以在CCLuaEngine里的executeNodeEvent,executeNodeTouchEvent,executeNodeTouchesEvent

里加上下面两句。

event["tag"]=CCLuaValue::intValue(pNode->getTag());

event["target"]=CCLuaValue::ccobjectValue(pNode,"CCNode”);

 

cocos2dx中的一些坑

原文:http://www.cnblogs.com/xdao/p/some_cocox2dx_hole.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!