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

  • 相关阅读:
    poj 3320 Jessica's Reading Problem
    uva 120 C
    vim使用教程-转自
    2015 俄罗斯网络赛 D. Boulevard
    HTML转义字符大全
    介绍个好点的,JAVA技术群
    JAVA学习路线
    linux常用命令大全(转)好东西要分享
    Jqprint 轻量级页面打印插件
    hadoop集群搭建
  • 原文地址:https://www.cnblogs.com/xdao/p/some_cocox2dx_hole.html
Copyright © 2011-2022 走看看