CocosIDE: Unable to import js-tests

I am using Windows 8.1, Cocos2dJS-3.0 rc1, CocosIDE, everything is 64bit.

I am following below steps in cocosIDE:
1)File->Import->General->Existing Projects into Workspace
2) Now I navigated to /samples/js-tests and selected it.
3) Clicked finish

It does normally what it does, that is, it tries to load project into workspace. But once it is done, it is not showing any project into my workspace and when I try to do these steps again, it says me that this project is already been imported.

Even restarting the IDE doesnot help.

Please tell me if similar is happening with you or how to fix it?

Thanks

CocosIDE doesn’t support js-tests directly from Cocos2d-JS package, if you want to use it with CocosIDE, do it as the following steps:

  1. Create a project with CocosIDE
  2. Copy js-tests’ resource (“res”,“src”,“main.js”,“project.json”) into the new project
    3.There have some searchpath code In js-tests Appdelegate.cpp, you need write to main.js

@chuanwei_zhang

Hey I think I got what you’re trying to say.

I replaced the new project’s main.js with the js-test’s main.js.


With the help of the link http://www.cocos2d-x.org/wiki/Mechanism_of_loading_resources
I added the below searchPath code:

vector searchPaths;
searchPaths.push_back("script");
searchPaths.push_back("src");
searchPaths.push_back("res");
searchPaths.push_back("res/scenetest");
searchPaths.push_back("res/scenetest/ArmatureComponentTest");
searchPaths.push_back("res/scenetest/AttributeComponentTest");
searchPaths.push_back("res/scenetest/BackgroundComponentTest");
searchPaths.push_back("res/scenetest/EffectComponentTest");        
searchPaths.push_back("res/scenetest/LoadSceneEdtiorFileTest");
searchPaths.push_back("res/scenetest/ParticleComponentTest");
searchPaths.push_back("res/scenetest/SpriteComponentTest");        
searchPaths.push_back("res/scenetest/TmxMapComponentTest");
searchPaths.push_back("res/scenetest/UIComponentTest");
searchPaths.push_back("res/scenetest/TriggerTest");

FileUtils::setSearchPaths(searchPaths);


And my final main.js looks like:

cc.game.onStart = function(){

vector searchPaths;
searchPaths.push_back("script");
searchPaths.push_back("src");
searchPaths.push_back("res");
searchPaths.push_back("res/scenetest");
searchPaths.push_back("res/scenetest/ArmatureComponentTest");
searchPaths.push_back("res/scenetest/AttributeComponentTest");
searchPaths.push_back("res/scenetest/BackgroundComponentTest");
searchPaths.push_back("res/scenetest/EffectComponentTest");        
searchPaths.push_back("res/scenetest/LoadSceneEdtiorFileTest");
searchPaths.push_back("res/scenetest/ParticleComponentTest");
searchPaths.push_back("res/scenetest/SpriteComponentTest");        
searchPaths.push_back("res/scenetest/TmxMapComponentTest");
searchPaths.push_back("res/scenetest/UIComponentTest");
searchPaths.push_back("res/scenetest/TriggerTest");
FileUtils::setSearchPaths(searchPaths);  

cc.LoaderScene.preload(g_resources, function () {

    if(window.sideIndexBar && typeof sideIndexBar.start === 'function'){
        sideIndexBar.start();
    }else{
		
        cc.director.runScene(new TestController());
    }
}, this);

};
cc.game.run();


Now after Running it in cocosIDE it gives me following error:

  1. In the Console:

main.js:19:SyntaxError: missing ; before statement
In the above main.js, this line 19 is:
vector searchPaths;

I don’t know how is it possible that ;(semicolon) is missing when it is already there.

  1. Syntax error on token “:”, ; expected
    in the following statement: (actually, it is red underlining the second colon of below statement)
    FileUtils::setSearchPaths(searchPaths);

Please help me to solve this problem…
Thanks

The final main.js is like this:

cc.game.onStart = function(){
cc.view.setDesignResolutionSize(800, 450, cc.ResolutionPolicy.FIXED_HEIGHT);
cc.view.resizeWithBrowserSize(true);

if (cc.sys.isNative) {
    var searchPaths = jsb.fileUtils.getSearchPaths();
    searchPaths.push('script');
    searchPaths.push('src');
    var paths = [
        'res',
        'res/scenetest',
        'res/scenetest/ArmatureComponentTest',
        'res/scenetest/AttributeComponentTest',
        'res/scenetest/BackgroundComponentTest',
        'res/scenetest/EffectComponentTest',
        'res/scenetest/LoadSceneEdtiorFileTest',
        'res/scenetest/ParticleComponentTest',
        'res/scenetest/SpriteComponentTest',
        'res/scenetest/TmxMapComponentTest',
        'res/scenetest/UIComponentTest',
        'res/scenetest/TriggerTest'
    ];
    for (var i = 0; i < paths.length; i++) {
        searchPaths.push(paths[i]);
    }
    jsb.fileUtils.setSearchPaths(searchPaths);
}

cc.LoaderScene.preload(g_resources, function () {
    if(window.sideIndexBar && typeof sideIndexBar.start === 'function'){
        sideIndexBar.start();
    }else{
        cc.director.runScene(new TestController());
    }
}, this);
  };
  cc.game.run();

@chuanwei_zhang

In your code why are you performing a check whether it is native or not?
if (cc.sys.isNative)

I mean, does that piece of code executes only when it is running using JSbinding for the platforms iOS/android/windows?

Thanks

Yes,you are right

I was having the same issue as catch_up.
However, after going through all the steps and applying chuanwei’s code to main.js the game module crashes a few seconds after start.
there is a “cocos2d: fullPathForFilename: No file found at /cc_2x2_white_image. Possible missing file.” warning but I don’t think that’s that

Thanks

You can don’t care about the warning.
Try Use “Run” button instead of “debug”.

Then if it is not native then how does it put the resources for HTML5 in search path or does HTML5 directly loads the resources using statement “cc.LoaderScene.preload(g_resources, function ()” without the need of putting the resources in searchpath?

:smile:

Thanks

@chuanwei_zhang
@toltec7

After so long I am trying solution you provided. I got the internet after a while :stuck_out_tongue:

When I Run As(not debug) ‘in Browser’ ’ it shows me following in the console:
D:\installation\Cocos2dx\cocos2dAdditional\cocos-code-ide-win64-1.0.0-rc0>
And doesnot result in anything after this.

But When I Run As(not debug) Cocos JSbindings’
It opens the application and shows blue screen with details on left bottom of the window, but doesnot show what it suppose to show. It is due to the following error in the console.

Console: listening on 0.0.0.0 : 6060
JS: D:/EDITOR DOCUMENTS/cocos/cocosIDE/cWorkspace2/ JStests_cocosIDE/ main.js:40:ReferenceError: TestController is not defined

(evaluatedOK == JS_FALSE)

How to fix this?
Why it is showing TestController is not defined. Do I need to add anything to project.json?

PS: It is creating problem in line(40th line)
cc.director.runScene(new TestController()); in main.js

try add source code and rebuild runtime,then select the runtime.

I’ve not understood what you mean with ‘try add source code’?

Also, its fine to rebuild runtime while running for native platform BUT why to run build time if I am trying to run it on browser. Or Do I still need to do it?

Thank You

Also, could you please tell me that if (cc.sys.isNative) is used loading resources for native platforms but
if it is not native then how does it put the resources for HTML5 in search path or does HTML5 directly loads the resources using statement “cc.LoaderScene.preload(g_resources, function ()” without the need of putting the resources in searchpath?

Hey it worked…

Thanks a ton for that :smile:

But can you please explain me the question in my last post

Thanks :smile:

Only JSB on native platform supports search path, you can not search a file on a server in html5 engine, so in html5, you need to specify all resources exact path for loading.
You can also use cc.loader.resPath to specify a root path of all resources (if they do share the same root path) to simplify the usage

cc.loader.resPath = "res/"
1 Like