zoukankan      html  css  js  c++  java
  • 如何使用ZEROBRANE STUDIO远程调试COCOS2D-X的LUA脚本(转)

    http://www.cocos2d-x.org/docs/manual/framework/native/v2/lua/lua-remote-debug-via-zerobrane/zh

    ZeroBrane Studio做为一个轻量级的Lua IDE,因为它支持跨平台(支持WindowsMacLinux)和支持真机调试(AndoridIPhoneIPad),所以经常被用来调试Lua。目前,Cocos2d-x通过集成LuaSocket也支持应用ZeroBrane Studio进行测试例的调试(Linux除外)。我们以HelloLua为例,详细描述如何使用ZeroBrane Studio进行iOS模拟器和Android真机的调试。

    版本

    • Cocos2d-x Version 3.0 Beta2

    iOS模拟器调试

    测试环境

    • ZeroBrane Studio (0.39 for mac; MobDebug 0.542)
    • Mac OS X 10.9
    • Xcode 5.01

    1.将ZeroBrane Studio.app/Contents/ZeroBraneStudio/lualibs/mobdebug/mobdebug.lua这个文件拷贝到cocos2d-x/samples/Lua/HelloLua/Resources目录下。这步过程在Cocos2d-x v3.0 Beta2及以上版本可以略过,引擎已经集成了这个文件。

    2.用Xcode打开cocos2d-x/build/cocos2d_samples.xcodeproj之后,先把mobdebug.lua文件加入HelloLua工程,然后在HelloLua/Resources/hello.lua文件里面添加debugger调用的指令,仅需要插入require('mobdebug').start()一句,插入在require "hello2"行之前,如下:

    local function main()
        ...
        require('mobdebug').start() --<-- only insert this line
        require "hello2"
        cclog("result is " .. myadd(1, 1))
        ...
    end    
    

    3.运行ZeroBrane Studio,点击界面从左上角的Project下面的...按钮, 然后选中cocos2d-x/samples/Lua/HelloLua/Resources目录,将HelloLua的Resources导入到Project下,如图所示:

    importResource.png

    4.打开hello.lua,鼠标点击行号右边的空白处加入断点:

    insertBreakPoint.png

    5.从ZeroBrane Studio的菜单栏开启Debugger Server:

    startDebuggerServer.png

    6.切换回XCode,运行HelloLua iOS测试例,触发断点(Windows环境下切换回Visual Studio 2012):

    enterBreakPoint.png

    7.通过debug工具栏,进行step in, step out, step over, continue等相应操作。此处需要注意,ZeroBrane有个地方比较奇怪,以local visibleSize = cc.Director:getInstance():getVisibleSize()这行函数为例,需要step over三次才能走到下一行函数,可能是因为此处有两个函数调用。

    debugBar.png

    8.点击View->Watch Window,打开Watch Window,添加要观察的变量:

    watchWindow.png

    watchValue.png

    9.点击View->Stack Window,还可以看到相应的堆栈信息:

    stackInfo.png

    Android真机调试

    测试环境

    • ZeroBrane Studio (0.39 for mac; MobDebug 0.542)
    • Android Developer Tools
    • HTC G17

    Android(IPhoneIPad)真机调试的流程和iOS模拟器调试基本相同,主要的区别在于hello.lua中debugger调用的指令,如下:

    local function main()
        ...
        require('mobdebug').start('192.168.1.110')
        require "hello2"
        cclog("result is " .. myadd(1, 1))
        ...
    end
    

    其中,192.168.1.110为PC的IP地址,测试手机的wifi IP需要与PC的IP地址同一网段,否则无法调试。

    http://blog.csdn.net/kenkao/article/details/46126103

  • 相关阅读:
    BZOJ1070: [SCOI2007]修车(最小费用最大流,思维)
    CF892D—Gluttony(思维,好题)
    BZOJ1005--[HNOI2008]明明的烦恼(树的prufer编码)
    HDU–5988-Coding Contest(最小费用最大流变形)
    【转】HDU 6194 string string string (2017沈阳网赛-后缀数组)
    【转】Codeforces Round #406 (Div. 1) B. Legacy 线段树建图&&最短路
    HDU6513/CCPC2017--A Secret(KMP)
    8.19-星期五
    CodeForces–830B--模拟,树状数组||线段树
    js实现360度图片旋转
  • 原文地址:https://www.cnblogs.com/softidea/p/5281094.html
Copyright © 2011-2022 走看看