One uses browser chrome to open the program for debugging. Same as normal JS program.
- Either build your own server, use a Python script, or use a different server program (lamp or XAMPP). Then use your browser to open the server address.
- Or just use Cocos to provide a good command line: Cocos run–p Web
The advantage of browser debugging is that it is convenient and very meaningful for small programs or non-native code. However, problems encountered after deployment to the real machine cannot be resolved, and some native code cannot be debugged.
Two use Firefox remote debugging.
Because Cocos2d-js uses SpiderMonkey as the JS parsing engine, this thing is the Mozilla faction, so use Firefox to do remote debugging. Off-topic ... This makes Firefox in the era of Chrome's heyday and found a sense of existence ah ~ ~ ~ really miss.
You can refer to Daniel's article:
http://goldlion.blog.51cto.com/4127613/1359572 But Daniel here has a flaw in the map, the address of the connection to the phone is not described. 127.0.0.1 is used when running with a native emulator, if it is a real machine, it must be the network address of the phone. This allows the development machine and the phone in the same WiFi network, and then to the router to find the IP phone, you can also use the development machine ping.
Debugging steps:
1 Firefox new edition (Test on V27)
2 opening the debug of the COCOS2D program
In AppDelegate.cpp (inside the framework), rewrite the appdelegate::applicationdidfinishlaunching () function, and add sc-> after Sc->start () Call of Enabledebugger ()
bool Appdelegate::applicationdidfinishlaunching () {//Initialize DirectorDirector*director =director::getinstance ();d irector-Setopenglview (Eglview::getinstance ());//turn on display FPSDirector->setdisplaystats (true);//set FPS. The default value is 1.0/60 if you don ' t call thisDirector->setanimationinterval (1.0/60); Scriptingcore* SC =scriptingcore::getinstance (); SC-Addregistercallback (REGISTER_ALL_COCOS2DX); SC-Addregistercallback (register_all_cocos2dx_extension); SC-Addregistercallback (register_cocos2dx_js_extensions); SC-Addregistercallback (register_all_cocos2dx_extension_manual); SC-Addregistercallback (jsb_register_chipmunk); SC-Addregistercallback (JSB_REGISTER_OPENGL); SC-Addregistercallback (jsb_register_system); SC-start ();ifDefined (cocos2d_debug) && (Cocos2d_debug > 0) SC-Enabledebugger (); #endifScriptEngineProtocol*engine =scriptingcore::getinstance (); Scriptenginemanager::getinstance ()-Setscriptengine (engine); Scriptingcore::getinstance ()->runscript ("Cocos2d-jsb.js");return true;}
3 Compiling run Cocos run–p Android
4 Firefox Connect phone
In Firefox, the menu item of the connection function is hidden by default, we need to change the browser configuration.
Do the following
So the menu item is displayed, and then.
Then, we connect the debugger and the device: ( address fill the phone's network address, the figure is 127.0.0.1 because the simulator is running; The port must be 5086)
A new window pops up to indicate that the connection was successful. Basic 1s is connected successfully, if not successful, then check whether the Cocos program is running, or the phone IP address is correct, or whether the development machine and mobile phone is on the same subnet.
5 Start debugging
Click the Debugger debugger to start debugging.
This method also has a certain flaw, that is, the Cocos program must be started before debugging. During the startup process, it is not easy to capture ... This time needs to use Cc.log to cooperate with a bit. Please refer to the previous log http://www.cnblogs.com/kenkofox/p/3906562.html for specific methods.