Cocos2d-x 3.0 beta trying to build some UI code on VS 2013

Hi,

I am using Cocos2d-x 3.0 beta and I am trying to use the UI Button
but I cannot get the include right. I have added libGUI into Visual Studio 2013.

Help please ? :slight_smile:

My code:

//MenuScene.h
#include "gui/CocosGUI.h"

//MenuScene.cpp
auto uButton = UIButton::create();

Errors:

error C1083: Cannot open include file: 'gui/CocosGUI.h': No such file or directory (..\Classes\TitleScene.cpp)

error C1083: Cannot open include file: 'gui/CocosGUI.h': No such file or directory (..\Classes\MenuScene.cpp)

IntelliSense: name followed by '::' must be a class or namespace name

IntelliSense: cannot open source file "gui/CocosGUI.h"

Try to add USING_NS_CC_EXT to your code.

That does not work… having same issue as well.

Sorry for late reply. I found that did not work for me either.

I am now trying to use v3.0 rc1 but cannot seem to get the auto project creator to work.
The previous version 3.0beta 2 had a good project creator, now in 3.0rc1 there is only a console one, which doesn’t work for me.

So I found a solution, although I am new to cocos2d-x and C++ in general so I dont know if this is the best solution possible (probably not )

I added the libGUI and libCocosStudio projects to the solution as your can see here.

Once that was done I was still getting errors cant find “x” file etc…
So In my main projects additional include directories i included the paths to the libcocosstudio project and the base cocos2d folder, since it seems to reference based on the base folder. such as.

So I added ($EngineRoot)cocos and ($EngineRoot)cocos\editor-support
The ui files reference one of the editor support headers so thats why u need it…

Now i can build and run the app with the new UI libraries.
For Example you should just be able to say…

#include "ui/CocosGUI.h"
cocos2d::ui::Button;

and it should compile. Might run into other issues but how far i have got so far…

What I think happened mainly is that they changed the folder to “ui” instead of “gui” but did not change the default include directions, so im not sure how to change those default include directories to work with the project.

Added the ticket here…
The solution i posted should work so enjoy for now :slight_smile:

http://www.cocos2d-x.org/issues/4739

One last thing to get it to work…
I also had to add the libExtensions project to my solution and build it because its needed by the new UI library.

I have it now running successfully using the new ui framework…

Very good. Thanks for you help. I will try sometime.