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

  • 相关阅读:
    python 函数参数
    文件操作总结
    时间模块总结
    代码编程规范
    javascript 学习
    Spring-扫描注解原理,注解自动扫描原理分析
    String中的intern方法
    Zookeeper服务注册与发现原理浅析
    一篇文章了解RPC框架原理
    如何设计一个秒杀系统
  • 原文地址:https://www.cnblogs.com/xdao/p/some_cocox2dx_hole.html
Copyright © 2011-2022 走看看