think of emscripten is a “compiler” – this translates the C++ code to (what we now use) WebAssembly (think of this as binary efficient javascript for the web browser).
that said, let’s try a demo. to use the files in the attached zip:
-
create a C++ First Person template, and NAME it: CPP_FP
-
unzip the attached zipfile and drop it in Source/.
-
package for HTML5
-
open a command prompt to your packaged output
-
run HTML5LaunchHelper.exe or python -m SimpleHTTPServer 8000 (again, from the where the packaged files are created)
-
open your browser to http://localhost:8000
-
open the developer tools via: Control+Shift+I (as in “eye”)
-
click on the Console tab in the developer tools window
-
back in the browser, click on CPP_FP.html
-
wait for the game to finish loading up
-
in the console tab – you should see foo printed in there, this will correspond to the C++ to JS call you will see at the end of ACPP_FPCharacter::BeginPlay() in CPP_FPCharacter.cpp
-
in the console tab, type the following:
-
MyProject_JSLibs.call_HTML5_to_UE4_function()
-
after pressing enter (which will demonstrate a JS to C++ call) – in the game (browser), you should see the character shoot a single round
i hope this is a clear example of your question.
you can diff the files before copying the zipped files to see what edits were needed to make this all work.