How to add support for web platform?

How to add support for web platform?
0

#1

I’m using following command to create new project.

cocos new MyGame -p com.MyCompany.MyGame -l cpp -d ~/MyCompany

but what i get in platform support Android, iOS, Mac, linux.

20%20PM 20%20PM

So my question is : How do i get Web platform as well for project? and yes i want to use cpp.(not lua or js)


#2

cpp doesn’t work for the web. You need javascript.


#3

So is there any work around to export cpp project for web or i must have to use js?


#4

Well, c++ uses OpenGL and OpenGL isn’t available for the web. WebGL is and that requires javascript.


#5

You can try to look at https://emscripten.org/
But I’m afraid you would have to do some heavy lifting yourself and the result may still be unpleasant (in terms of loading speed/distribution size). You can search for ‘cocos2dx + emscripten’ to find something useful but at the end that is no supported officialy so it’s up to you to do a lot of work.

On the other hand, if the project is not as complex, then you could look for another (less popular/less developed) C++ engine that already have emscripten/asm.js/wasm support.