How to use live coding?

I’m looking at Cocos Code IDE (awesome work! btw) and I can’t figure out how to use this feature:
http://www.cocos2d-x.org/wiki/How_to_Debug_Cocos2d-JS_Game_Using_Code_IDE#Code-Hot-Updating

Where should I place code such as that of the example so it’s executed when the file is saved?

extra: Also, I’m used to just debugging in Chrome, and in there I have the ability to pull up the JavaScript command line and simply type code to be executed in that moment… Is there a way to do this when debugging with this IDE?

extra2: is there a way to boot up chrome/other browser from within the IDE besides the options to execute as windows/android/ios application? (instead of having to navigate to the folder and use the cocos -run -p web command).

@ZippoLag, there is some bugs about code-hot-updating for cocos2d-js 3.0 rc1, next week(around 2014.07.29), cocos2d-js 3.0 rc2 will fix this bug, and the code-hot-updating will support any codes placed in project.

and, Code IDE have not supported debugging Chrome,
but you can click the “Run in Browser” button instead of using cocos -run -p web

I see… Thanks!

Even still… I’m not quite sure I’m understanding where I should place the code for it to work…

For example, let’s say I have a loop in which I create a bunch of sprites and add them to a layer, and then I never change their attributes outside of that loop: how could I edit them while running so live coding would detect and apply these changes?

Also, does execution have to be halted in a breakpoint or something like that for live coding to work?

Could you guys maybe make a very short explanation / tutorial beyond that lone paragraph and code sample currently on the docs? :slight_smile:

Presently, code-hot-updating means updating changed files and restarting main.js/main.lua(or any other entry script file) without restart game.

Hi, @honghui_zhang:
I want to know some detail about how the live coding mechanism works, because the Code IDE works too slow and lag for me, and I want to Hot update code manually.

I am working on Cocos2d-js engine , and My plane is:

  1. Code in Sublime text or some text editor, and open my APP in simulator or device.
  2. Hot update code manually, then the code will take effect in my APP.

So, would you please help me or give me some advises about this? Thank you.

Can anybody else help me about this?

I think you can see the Runtime.cpp.
First Simulator start a FTP server, then you can upload the changed files and use console command to reload the script.

Thanks, you are right!
I have read this Runtime.cpp source code, and I understand the mechanism now. I am trying to analyze the usage of the console command…

BTW, Do you have some related wikis or articles recommend? I can’t google anything about this. I am learning this in my spare time, analyze these things from source code is too slow and annoying.

Thank you so much.

Sorry, I don’t find any related wikis or articles recommend too. but if you want to know the code ide command, you can add some code in Runtime.cpp, in ConsoleCustomCommand's onSendCommand

 void onSendCommand(int fd, const std::string &args)
 {
 Director::getInstance()->getScheduler()->performFunctionInCocosThread([=](){
            rapidjson::Document dArgParse;
            dArgParse.Parse<0>(args.c_str());
            CCLOG("%s", args.c_str()); // add this code to print the command
}
// other code
}

In code ide start a game you will see the command format like this:

If you live coding in other editor, please tell me too .
Good luck. :smile: