# Cocos2d-x 下斷點 使用LuaHelper ## LuaHelper 是騰訊開發的工具 支援unity的xlua slua ooxxlua外 也支援cocos2d-x的lua ## 下斷點設定步驟 * VSCode 開啟Inanna資料夾 * VSCode尋找插件尋找Lua並安裝 * ![image](https://hackmd.io/_uploads/BkoGbtt7R.png) * 生成launch.json * ![image](https://hackmd.io/_uploads/BywxgYFmR.png) * 調整一些參數 * ![image](https://hackmd.io/_uploads/rJKJ6OFXC.png) * "distinguishSameNameFile": true * 引入LuaPanda.lua文件 * ctrl + shift + p * ![image](https://hackmd.io/_uploads/r1vGTuKQ0.png) * LuaHelper: Copy debug file to workspace * 將LuaPanda.lua放在proj.win32\Debug_Opt.win32\InannaLua下 * 修改PreLoad.lua * ![image](https://hackmd.io/_uploads/SkxRp_FX0.png) * 插入require("InannaLua/LuaPanda").start("127.0.0.1",8818) * 更新LuaPanda * ![image](https://hackmd.io/_uploads/SyfGRdtXR.png) # 自動同步設定步驟 * VSCode尋找插件尋找Trigger Task on Save並安裝 * 新增這兩個檔案 * ![image](https://hackmd.io/_uploads/BJpnIOrVC.png) * [settings.json](#settings.json) * [tasks.json](#tasks.json) ## 使用步驟 * VSCode 按 F5 開始監聽 * VS執行滿貫 * lua存檔後會自動同步 ### 出處 https://github.com/Tencent/LuaHelper/blob/master/docs/manual/usedebug.md ## 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": [ { "type": "LuaHelper-Debug", "request": "launch", "name": "LuaHelper-Attach", "description": "通用模式,通常调试项目请选择此模式", "cwd": "${workspaceFolder}", "luaFileExtension": "lua", "connectionPort": 8818, "stopOnEntry": false, "useCHook": false, "autoPathMode": true, "distinguishSameNameFile": true }, { "type": "LuaHelper-Debug", "request": "launch", "name": "LuaHelper-DebugFile", "description": "独立文件调试模式", "luaPath": "", "packagePath": [], "luaFileExtension": "", "connectionPort": 8818, "stopOnEntry": true, "useCHook": true } ] } ``` # settings.json ![image](https://hackmd.io/_uploads/HyjZ-wHE0.png) ``` { "files.associations": { "*.lua": "lua" }, "C_Cpp.default.browse.limitSymbolsToIncludedHeaders": true, "files.exclude": { "**/*.cpp": true, "**/*.obj": true, "**/CocoStudioProject": true, "**/Debug_Opt.win32": true, "**/Debug_package.win32": true, "**/Debug.win32": true, "**/Inanna.xcodeproj": true, "**/InannaResource": true, "**/Inanna": true, "**/include": true, "**/release_Opt.win32": true, "**/ThirdPartyLib": true, "**/src": true, "**/*.mk": true, "**/*.vcxproj": true, "**/*.sln": true, "**/*.filters": true, "**/*.user": true, "**/*.h": true, "Tools": true, } } ``` # tasks.json ``` { "version": "2.0.0", "tasks": [ { "label": "Run Batch Script on Save", "type": "shell", "command": "./SyncFiles.bat", "problemMatcher": [], "runOptions": { "runOn": "folderOpen" }, "presentation": { "echo": true, "reveal": "always", "focus": true, "panel": "shared" } } ] } ```