You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Almas Baimagambetov edited this page Jan 5, 2017
·
1 revision
Typical use case for JavaScript code includes external scripts that can be easily changed at runtime and used in multiple projects. JS code is evaluated by the nashorn engine, so the reader is also referred to this page, which explains how to use Java code from scripts.
Entity Behavior
It is possible to implement entity behavior in JavaScript. Essentially JS code is wrapped with a Control.
For example, in Java we can add a JS script as follows:
functionsomeFunction(){// FXGL is a globally accessible object that provides the same functionality as it's Java counterpartFXGL.getNotificationService().pushNotification(...);// APP is another object that can be accessed globally and holds the reference to the GameApplication instancevarwidth=APP.getWidth();}