For a while the Greenfoot development team have been working on a solution to the problem of Java applets becoming increasingly difficult to run in modern browsers.
I'm pleased to announce that we have a solution, which should currently be considered "apha quality", for automatically converting Greenfoot scenarios to Javascript - so that they can run in any web browser (possibly including some smartphones), regardless of whether the Java plugin has been installed.
I'm now opening this up to all members of the Greenfoot site so they can begin experimenting with the implementation and report any problems (but please read this entire message before posting a response - thanks!).
To view the Javascript version of a scenario, simply append "?js=true" to the scenario URL. For example, to view Nosson's Brick Breaker scenario, go to the following URL:
http://www.greenfoot.org/scenarios/18105?js=true
The following limitations apply to scenario conversion:
- Only Greenfoot 3.1.0+ scenarios are supported. Scenarios using the old API, including the java.awt.Color class, will not work. However, some older scenarios might work.
- The complete Java API is not available (although most commonly used API is working). In particular, AWT and Swing are missing, and will never be provided. The getAwtImage() method from GreenfootImage will not work.
- The Javascript generated is only expected to work in modern browsers. Use Firefox, Chrome, Safari, or Internet Explorer 1011 (or Edge). (edit) Internet Explorer is more likely to exhibit issues than the other browsers due to its lack of compliance with standards. There will probably never be official support for older versions of Internet Explorer.
- Support for different sound formats is browser dependent. Some phones in particular might be able to play mp3 files but not wav files. (edit: Internet Explorer is also unable to play wav files).
- Sounds do not stop playing when the scenario resets
- Reset does not work correctly for all scenarios
- Mouse drags do not work when the mouse cursor leaves the world (should be fixed now).
- UserInfo isn't working at all, yet.
- On phones/tablets scenarios might not respond to input (should be fixed).
- On Internet Explorer, which does not support playing .wav files, scenarios trying to play .wav files will crash or not load (fixed, though wav files won't play they won't cause a crash).
- On Internet Explorer, keyboard input isn't recognized (at least for arrow keys) (fixed).
- On Internet Explorer, dragging the mouse outside the world will cause text selection (fixed).
- If a scenario fails to load, no suitable error message is displayed.
- Loading resources (text files, etc) using ClassLoader doesn't work (fixed).