cocos2dx客户端添加使用vscode及插件local lua debug进行调试

1.安装vscode local lua debug插件

2.修改mac/SimulatorApp.mm文件 updateProjectFromCommandLineArgs:(ProjectConfig*)config 函数将

    config->setShowConsole(true); 中的true改为false,就是关闭控制台窗口,否则调试插件不生效

3.添加或修改.vscode/launch.json 代码如下,根据实际路径适当修改

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Release",
            "type": "lua-local",
            "request": "launch",
            "program": {
                "command": "/Users/ycmac/develope/rok-client/runtime/mac/LOR Mac.app/Contents/MacOS/LOR Mac"
            },
            "args": [
                "-n",
                "-a",
              "${workspaceFolder}"
            ]
        },
        {
            "type": "lua-local",
            "request": "launch",
            "name": "Debug",
            "program": {
              "command": "/Users/ycmac/develope/rok-client/runtime/mac/LOR Mac.app/Contents/MacOS/LOR Mac"
            },
            "args": [
            "-n",
            "-a",
              "${workspaceFolder}"
            ] ,
            "scriptRoots": [
                "/Users/ycmac/develope/rok-client/src"
              ]
          }
          
    ]
}

4.在 src/main.lua中添加如下代码加载调试模块,(被注释的两行)

require("cocos.init")
require("framework.init")

--package.path = '/Users/ycmac/.vscode/extensions/tomblind.local-lua-debugger-vscode-0.2.0/debugger;' .. package.path
--require("lldebugger").start()


-- -- ============= 三消调试 START =============
-- GAME_VERSION     = "0.00.001"
-- GAME_MIN_VERSION = "0.00.001"

因为在启动时开启调试影响性能,可在游戏启动后打开调试如下,例如可在view/mainCityView.lua文件中添加
 


--点击触发监听层
function mainCityView:viewOnClick(ref, event)

    
    
    if not lldebugger then
        lldebugger = {}
        package.path = '/Users/ycmac/.vscode/extensions/tomblind.local-lua-debugger-vscode-0.2.0/debugger;' .. package.path
        require("lldebugger").start()
    end
    
    
    mainCityHandler.viewOnClick(self, ref, event)    
end
--缩放监听

这样在游戏启动后点击一下主界面,就可以调试了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值