zoukankan      html  css  js  c++  java
  • cocos2dx中的一些坑

    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”);

  • 相关阅读:
    hdu 2044 一只小蜜蜂
    HDU 2041 超级楼梯
    卡特兰数
    hdu 1267 下沙的沙子有几粒?(二维递推题)
    大数加法、乘法
    学习时仪式感太强是不是不太好
    php记日志
    cygwin安装apt-cyg
    存储过程死循环之后的清理
    linux的计划任务crontab
  • 原文地址:https://www.cnblogs.com/xdao/p/some_cocox2dx_hole.html
Copyright © 2011-2022 走看看