How to handle search paths and graphics in Windows project? (got it working, mostly!)

I’ve gotten my Windows project to build. This project already runs on Android and iOS devices, and I’ve just begun the effort to add a win32 version. I had to comment out the places where I use pthreads, but ok, I just want to get it to run.

However, now I’m stuck on loading resources. In my AppDelegate, which I wrote when I started out with cocos2d-x version 3.4, I have two different arrays of folders (paths) - one for loading images (so that it’ll load the highest resolution first, if available), and one for searching for files, such as audio files.

This works great in all iOS and Android phones and tablets. However, I can’t figure out how to get the resources into my Visual Studio project. I can “add existing items” but can’t select folders.

I would appreciate any guidance, thanks!

Update - I’ve gone in and manually created filters under “resource” but that hasn’t helped either.

My background images are laid out like this:
backgrounds
|-- ipad
|--
|-- ipadhd
|--
|-- iphone
|--
|-- iphonehd
|--
|-- iphonehd5
|--

and this works for the iOS and Android devices, but windows isn’t seeing the background image I’m specifying.

UPDATE: I’ve gotten it working! However, it’s a little 480x320 window. I’m going to see if I can’t get a larger display to work. This is pretty awesome, though, and is an indicator of just how awesome cocos2d-x is!

look in AppDeleagte, it has both of your answers on how to add search paths and the 480x320 size.

Example:

 auto screenSize = glview->getFrameSize();
    auto designSize = Size(480, 320);

    auto fileUtils = FileUtils::getInstance();
    std::vector<std::string> searchPaths;
    
    if (screenSize.height > 320)
    {
        auto resourceSize = Size(960, 640);
        searchPaths.push_back("hd");
        searchPaths.push_back("ccs-res/hd");
        searchPaths.push_back("ccs-res/hd/scenetest");
        searchPaths.push_back("ccs-res/hd/scenetest/ArmatureComponentTest");
        searchPaths.push_back("ccs-res/hd/scenetest/AttributeComponentTest");
        searchPaths.push_back("ccs-res/hd/scenetest/BackgroundComponentTest");
        searchPaths.push_back("ccs-res/hd/scenetest/EffectComponentTest");
        searchPaths.push_back("ccs-res/hd/scenetest/LoadSceneEdtiorFileTest");
        searchPaths.push_back("ccs-res/hd/scenetest/ParticleComponentTest");
        searchPaths.push_back("ccs-res/hd/scenetest/SpriteComponentTest");
        searchPaths.push_back("ccs-res/hd/scenetest/TmxMapComponentTest");
        searchPaths.push_back("ccs-res/hd/scenetest/UIComponentTest");
        searchPaths.push_back("ccs-res/hd/scenetest/TriggerTest");
        searchPaths.push_back("ccs-res");
        searchPaths.push_back("Manifests");
        director->setContentScaleFactor(resourceSize.height/designSize.height);
        
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIButton");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UICheckBox");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIImageView");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILabel");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILabelBMFont");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/BackgroundImage");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/Color");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/Layout");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/Gradient_Color");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILayout/LayoutComponent");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UILoadingBar");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIPageView");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIScrollView/Both");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIScrollView/Horizontal");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIScrollView/Vertical");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UISlider");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UITextField");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIWidgetAddNode");
        searchPaths.push_back("ccs-res/hd/cocosui/UIEditorTest/UIListView/New");
        
        searchPaths.push_back("ccs-res/hd/cocosui/CustomTest/CustomWidgetCallbackBindTest");
        searchPaths.push_back("hd/ActionTimeline");
        searchPaths.push_back("ccs-res/hd/armature");

        searchPaths.push_back("ccs-res/hd/scene3DTest");
    }
    else
    {
        searchPaths.push_back("ccs-res");
        searchPaths.push_back("ccs-res/scenetest/ArmatureComponentTest");
        searchPaths.push_back("ccs-res/scenetest/AttributeComponentTest");
        searchPaths.push_back("ccs-res/scenetest/BackgroundComponentTest");
        searchPaths.push_back("ccs-res/scenetest/EffectComponentTest");
        searchPaths.push_back("ccs-res/scenetest/LoadSceneEdtiorFileTest");
        searchPaths.push_back("ccs-res/scenetest/ParticleComponentTest");
        searchPaths.push_back("ccs-res/scenetest/SpriteComponentTest");
        searchPaths.push_back("ccs-res/scenetest/TmxMapComponentTest");
        searchPaths.push_back("ccs-res/scenetest/UIComponentTest");
        searchPaths.push_back("ccs-res/scenetest/TriggerTest");
        
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIButton");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UICheckBox");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIImageView");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILabel");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILabelBMFont");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/BackgroundImage");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/Color");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/Layout");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/Gradient_Color");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/Scale9_BackgroundImage");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILayout/LayoutComponent");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UILoadingBar");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIPageView");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIScrollView/Both");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIScrollView/Horizontal");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIScrollView/Vertical");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UISlider");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UITextField");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIWidgetAddNode");
        searchPaths.push_back("ccs-res/cocosui/UIEditorTest/UIListView/New");
        
        searchPaths.push_back("ccs-res/cocosui/CustomTest/CustomWidgetCallbackBindTest");
        searchPaths.push_back("ActionTimeline");
        searchPaths.push_back("ccs-res/armature");

        searchPaths.push_back("ccs-res/scene3DTest");
    }
    
    fileUtils->setSearchPaths(searchPaths);

Thanks. I got it working, but I’ve also experimented with bumping up the size, since I find 480x320 way too small. I like the iPhone 5 or iPad Hd images and sizes the best.

I have to say, I’m extremely impressed with the cocos2d-x functionality, that I was able to get this working in such a short time! I will have to redo the pthreads work, but other than that, everything is great!

I might also look to see if there’s a way to run maximized, like I do with the games I play, where I have the option to run as a window or full-screen.

thanks again!

p.s. I’ll definitely try your approach later. I have to break for family now, but you took a different tack than I did. Thanks much!

I think @corytrese runs full-sized windows.

1 Like

Thanks @slackmoehrle. Again, I’m just thrilled silly with this. I have ONE code set, with some small places where I check on the specific platform, and can support Android, iOS, and now Windows. That’s stinking amazing! I’ll have to add the Mac later.

All the cocos2d-x people deserve massive kudos!

If you’re interested (and I’m not saying this to advertise, but just to point to a game that’s built on cocos2d-x), my apps are “Pro Strategy Football” and “Pro Strategy Football Career.” I wrote the original in objective c, but many of the computation files were simply C, so I had to rewrite only the objective c files in C++ this year. Went well!

You can always advertise your games in our “Game/Demo Showcase” category

1 Like