You can add javascript to your game, but there is a problem.
No actual “JavaScript Event” exists in the Events tab.
there is only a “JavaScript code (Web platform …)” and that is not what I want.
So I tried External sources… created that, added it to my game and it looks exactly as on the image in the tutorial, but.
You have to call your functions using a “JavaScript Event” and that one doesn’t exist…
What am I doing wrong ?
Edit: SOLUTION
1.Write a function in your external source and give it a parameter.
2.In “Events” tab create a “JavaScript code” and call the function using sing the instance of whatever you are trying to access as the parameter.
@Bouh So if I get you correctly
I create an external source, in there I write all the functions, then I use the javascript code event and put in the name of the function from the external file >> no reference required ?
You need to pass the “runtimeScene” variable as a parameter of your external code function (as runtimeScene is only available for javascript inlined inside the javascript event).
I meant that when I want to use e.g. gdjs.RuntimeObject I have to use “runtimeObject” as a variable passed in my external file, and similarly to the rest of the gdjs.______.classes. I’ll give it a try and report back.
Edit: Ok I was being stupid … I had it set up properly, but I kept executing my code from Chrome’s JS console.
Now it is working.
Thanks @victor and @Bough