Is Cocos2d-x suitable for Windows & Android development?

Is Cocos2d-x suitable for Windows & Android development?
0

I would like some suggestions and advice from the community please.
Is cocos2d-x a good engine to learn for Windows and Android games?

I want to make a game on Windows and Android - if it works on Apple IOS that is a bonus. It is a tile based adventure game, and I have years of C++ experience , so Cocos2D-x seemed a good choice for a hobby project.

However, after spending several days with V3.17.1 I am beginning to think Cocos is mainly for IOS and buggy on Windows 10 (I have not tried Android yet).
Now it seems V4 removed OpenGL and only support Metal (for Apple I assume), making me wonder if there is a point learning cocos2d-x if I want to program for Windows and Android.

I worked from several old tutorials I found online, and I expected some challenges since some are old. I did not expect the coordinate error I am getting from touch and mouse events - In particular mouse coordinates seem to give semi random numbers. And the locations when converting between OpenGL and Cocos’ draw coordinates seem way off. Basically when I draw on mouse or touch coordinates it is in wrong y location (and not just y axis flip, there is offset and seemingly random y value coordinates too). This seems a surprising thing to have obvious bug, unless Windows not really supported.

I had hoped V4 would fix this, but now it seems V4 has no OpenGL only Apple Metal.

I would really like to like Cocos2d-x but I’m wondering if it is the right choice for Windows and Android or if there are more suitable game development engines for my purposes.

I get the impression Cocos is not used or tested much on Windows, and this will be worse with Metal focus in V4 - but perhaps I am wrong?

Is it a mistake to start learning Cocos2d-x for use on Windows and Android?

Perhaps another engine focused more on Windows would be better (suggestions)?

Is Cocos not well supported on Windows and Android? Will the switch away from OpenGL be a problem for those platforms?

Or am I just having beginner trouble, and should ask for help on how to do a simple line draw from (0,0) lower-left-corner to touch and mouse click position, when running on Windows 10. Perhaps I am missing something silly.

It seems like things that should be easy in a game engine are surprisingly hard.

Thanks

Your post is filled with a number of assumptions and misinformation. It’s hard to sort through this all

Bottom line is cocos is very mature on Windows and Android and you should use newer examples since v2 to v3 was a huge re-write and perhaps the old tutorials you are referring to were v2

Also cpp-tests has working examples of most engine functionality. Please take a look for more touch and coordinate help. Post code if you still get stuck.

In Cocos2d-x v4, OpenGL is used for Windows, Linux and Android, and Metal is only for Apple platforms.

I’m pretty sure there are many games released on the Windows platform using Cocos2d-x, and with a quick search of this forum I’m sure you’ll find references to them. As for your remark regarding Metal in V4, perhaps it’s best to read up on V4 to gain an understanding of how the new rendering code works.

Hi slackmoehrle and R101,
Thanks for your quick reply - I did not expect that :smiley:

I would say impressions and lack-of-information is all I have at this point, which is why I’m asking questions :slight_smile:

Good to know. I obviously was getting the wrong impression from most of the examples I found on-line, and yes I suspect they are old (although one did refer to V3).
Since Cocos2d-x is successfully used on Windows, I will assume it is my newbie mistakes that is the problem. The mouse problem has all the smells of some uninitialized pointer, so I probably skipped an important step :roll_eyes:
Thanks for suggesting cpp-tests, I’ll play around a bit more over the holidays.

Ah, I did not realize that R101. That is good information. I wonder how similar a ported program between Metal and OpenGL will be - I suspect Metal will perform better…

Thanks for your help and feedback.
If I’m still stuck after looking at the test cpp I’ll post some code and ask for help.

Yup, let us know, we can get things worked out for you. We do require a bit or a learning curve compared to other game engines.

https://docs.cocos2d-x.org

This essentially fixed my problem

Thanks for helping a newbie out slackmoehrle

Just in case anyone is curious:

The cpp-test project seems to work fine on Windows 10 with Visual Studio 2017*, Cocos2d-x V3.17.2.

I ran the “11:Click and Move” test, and it works just fine with no problems re Y axis touch and mouse position on Windows 10.
Obviously I missed something when working of possibly older tutorials found on-line.

Judging by the test names it looks like the tests are the perfect examples to learn how to do stuff from, where dated tutorials may not be.

Thanks for the support / suggestions. Time to find out why the Y-Axis mouse is messed up on my own code. As usual, knowing it works and examples is most of the battle.

*I had to manually include libcocos2d, librecast, and libSpine projects in solution, fix dependencies and add libcocos2d resource to cpp-test project to make it compile. For some reason the win10 projects had problems compiling but the win32 ones worked fine.

If you need help. Post some code and we can try it on our end too.

I think he is not a 100% wrong. I must add that in V4 it seems like developers forgot or removed cursor functions for desktop platforms:

GLFWcursor* _cursor;

was removed from CCGLViewImpl-desktop.h in v4

this was also removed from CCGLView.h in v4:

	virtual void setCursor(const std::string& filename, Vec2 hotspot = Vec2::ANCHOR_MIDDLE) {}

	virtual void setDefaultCursor() {}

I also added this in v3 and v4:

virtual void setCursorPosition(double x, double y) {}
and i use it to set the cursor in a fixed position so i can rotate the camera in a 3d scene like a first person shooter and then the cursor doesn’t go out the screen.
Also added this because if you switch to fullscreen there is a variation in the position of cursor:
virtual cocos2d::Size getMonitorResolution() { return cocos2d::Size::ZERO; }
(with their corresponding overrides, If you want detailed implementation ask and i ll share.)

So i said he is not a 100% wrong because this functions are useful in desktop platform games, and the fact that were removed or maybe just forgotten means you are not really paying a 100% attention to desktop platform.

There is also a bug in v3 when switching to fullscreen like 3 or 4 times: u get the window in the top left corner and cant not be moved, also the first time switching to full screen the image get stretched, then it don’t get stretched anymore the next times you change to fullscreen again. I didn’t research on last one, but the first one can be tested on cpp-tests.

Hi lmartinignacio.

Thanks for your input.
That is a bit concerning.

Personally I prefer desktop gaming (old school I guess), and since this is mainly a hobby project for my own amusement, desktop is intended as primary platform (although it would be nice if it works on my Android phone too).

Hopefully the lack of desktop related mouse stuff you noticed is an oversight or deferred for V4.1 so devs could make their release target (being a software engineer I am familiar with how the feature / deadline tradeoffs work :thinking: so I can relate if the devs had to defer for V4.1).
If it is actually cut, it would imply Cocos2d may not be long-term suitable for the desktop.

I too noticed some odd dual screen effects, but too be fair to Cocos, I have seen this in many other programs too. As far as I can tell some manufacturers / Windows have problems here, in particular if you mix screen resolutions and hardware (like a laptop with monitor). It seems Windows or the drivers may be feeding incorrect resolution information back - at least that was the case in one App I worked on using Qt.

Thanks, I’d be interested, that sounds like useful functionality.

I’ll make a clean project and ill share those functions, i can’t right now.

Just to clarify, I believe cocos2d-x is one of the best game engines in the market, those are just details which took me 3 mins to fix (now that i know the engine) but the first time took me a few hours. I would like to create PR to contribute but i’m not sure how to do it properly.

If you are familiar with git you can do this from a command-line and then goto the issues tab in our repo and your PR will show up for you to finish creating from there. You can reach out to me if you need help. Read this, the submitting patches section a bit down the page.

In case some one else has this problem:
The tutorial I worked of was missing a call to
GLView.setDesignResolutionSize(…);
Adding that fixed problem with random seeming y values for mouse coordinate.

@slackmoehrle this is the PR:

Any feedback if it was properly done will be very helpful. :smiley:

There you can check all the changes in code, i also added a test case on mouse tests with a first person shooter demo.

I found this function:
Director::getInstance()->getOpenGLView()->getFrameSize();
which does the job and i didn’t need to implement this one mentioned before:

PR is building right now.

here is a video (sry for the bad quality fullscreen didn’t work with recorder)

2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.