This site requires JavaScript, please enable it in your browser!
Greenfoot back
Back to discussions
davmac
davmac wrote ...

2017/9/5

HTML 5 scenarios are here!

1
2
davmac davmac

2017/9/5

#
As some of you will no doubt have already noticed, The HTML 5 version of scenarios are now presented by default. This has several advantages:
  • faster load times
  • the Java plugin is no longer required to play scenarios online
  • scenarios will now run on many smartphones and tablets
  • the UserInfo (high score) functionality works again with minimal fuss
Production of a HTML 5 scenario occurs through an automated translation of the original Java scenario into Javascript. This process has some limitations, which have been previously discussed; most importantly, Swing and AWT classes cannot be used which means that scenarios using the "java.awt.Color" and "java.awt.Font" classes will not translate successfully. Greenfoot 3.1.0 introduced replacements for these in the form of "greenfoot.Color" and "greenfoot.Font", so we recommend upgrading to Greenfoot 3.1.0 if you are still using an older version. In the near future, we also plan to allow running HTML 5 scenarios in a "full screen" mode (which should be particularly useful for running on phones and tablets), and to allow embedding scenarios in other web pages (much as you can embed videos from Youtube, for example). Scenarios for which translation to HTML 5 was not successful can still be played by following the link to the legacy (applet) version, which requires the Java plugin. If you have created scenarios which didn't translate successfully to HTML 5, viewing the scenario page while logged in should show you the log generated during the translation process which may give a hint as to what caused the failure (quite often, it will be due to use of an unsupported part of the Java API). There may be some minor teething problems, so if you notice problems with the HTML 5 version of a scenario, feel free to discuss them here.
Yehuda Yehuda

2017/9/6

#
In my Stopwatch scenario the text is very small - not the Font it's meant to be. (Like it is here)
davmac davmac

2017/9/6

#
Ok, I've fixed that issue now. Thanks for reporting it.
AuroraGamer AuroraGamer

2017/9/7

#
What if you can't update to 3.1.0?
davmac davmac

2017/9/7

#
AuroraGamer wrote...
What if you can't update to 3.1.0?
Then your scenarios are likely to not translate to HTML 5 successfully (as is explained above). However, there aren't many reasons I'm aware of why anyone wouldn't be able to update to Greenfoot 3.1.0. Note that if you use older versions of Greenfoot but only use the API that is equivalent to that in 3.1.0 (i.e. you avoid use of java.awt.Color and java.awt.Font, and any other AWT/Swing classes), your scenario may still be translatable to HTML 5.
AuroraGamer AuroraGamer

2017/9/8

#
davmac wrote...
Then your scenarios are likely to not translate to HTML 5 successfully (as is explained above). However, there aren't many reasons I'm aware of why anyone wouldn't be able to update to Greenfoot 3.1.0.
Old macbook that can't upgrade past Mac os x 10.6
davmac davmac

2017/9/9

#
AuroraGamer wrote...
davmac wrote...
Then your scenarios are likely to not translate to HTML 5 successfully (as is explained above). However, there aren't many reasons I'm aware of why anyone wouldn't be able to update to Greenfoot 3.1.0.
Old macbook that can't upgrade past Mac os x 10.6
Ok, but I don't think many people are in that position. I hope the above is all pretty clear - if you use some portions of the older Greenfoot API then your scenario won't translate. You can still upload it to Greenfoot.org and the legacy applet version will still be there (it is not shown by default, but you can follow the "legacy version" link from the scenario page).
yedefei yedefei

2017/9/14

#
There's a problem when I update my scenario to H5 ,that I cant use the right button of mouse ,by which the tanker would project bullets。 Here's the link of scenario : http://www.greenfoot.org/scenarios/5769 how to solve?
davmac davmac

2017/9/18

#
yedefei wrote...
There's a problem when I update my scenario to H5 ,that I cant use the right button of mouse ,by which the tanker would project bullets
That's correct, currently the right mouse button is not recognised. We'll address that in an update soon. You don't need to do anything, it will be fixed when the scenarios are automatically re-translated.
valdes valdes

2017/9/23

#
@davmac, in my scenario Tutorial I get the following error:
INFO: Building JavaScript file
INFO: Output file built with errors
ERROR: Method java.lang.ClassLoader.getResource(Ljava/lang/String;)Ljava/net/URL; was not found
    at TextFileViewer.<init>(TextFile
The scenario displays text files, so I use java.net.url. Will that class get support in HTML5 version ? or can you recommend some alternative?
davmac davmac

2017/9/23

#
valdes wrote...
Will that class get support in HTML5 version ? or can you recommend some alternative?
That method - ClassLoader.getResource() - might or might not be supported in the future. However, ClassLoader.getResourceAsStream() is already supported and in general is more useful. It allows you to avoid using java.net.URL.
danpost danpost

2017/10/5

#
I noticed in my most recent scenario upload that the HTML5 version appears to be locked as far as dragging actors around in the world although it was uploaded as unlocked. Was this intentional or can it not be re-implemented? (or something else)
davmac davmac

2017/10/9

#
danpost wrote...
I noticed in my most recent scenario upload that the HTML5 version appears to be locked as far as dragging actors around in the world although it was uploaded as unlocked. Was this intentional or can it not be re-implemented? (or something else)
Sorry for the slow reply. That's not actually intentional, just a use case that wasn't properly considered (not "locking" a scenario should have two effects: you can adjust the speed slider, and you can drag objects around when the scenario is paused; we forgot about the second one). However, it's not trivial to re-implement. I'll file a note on this and see if I can try to fix it at some point (but it probably won't happen quickly, sorry!).
danpost danpost

2017/10/9

#
davmac wrote...
< Quote Omitted > Sorry for the slow reply. That's not actually intentional, just a use case that wasn't properly considered
Response noted. Thank you.
danpost danpost

2017/10/18

#
I am finding some differences between how the scenarios look and run in the greenfoot application and how they do on the site in HtML5. Some images appear different and text images are often larger in HTML5; the scenario speed are not at all consistent; and, I have one scenario that freezes in HTML5 -- namely my Bee Quick (ImgScroll demo) scenario (when spawning connections -- Web objects). Its score and timer actors are an example of a difference in images (see the legacy version for comparison).
There are more replies on the next page.
1
2