Skip to content

[GREENFOOT-194] Needing JavaScript-Controlable Greenfoot-Viewer-Applet

Hello,

it would be nice to be able to control Greenfoot with JavaScript. I think there is only one method to implement for this that returns the world like the following:

{noformat} public World getWorld() {return world;} {noformat}

Then I can go on with the public methods of the world. There should be added:

{noformat} public Object doEval(String cmd) { return eval(cmd); } {noformat}

I would like to use it in a JScript that has wrapper functions like the following:

{noformat} function createObject(objectid, x, y) { var world=document.greenfootApplet.getWorld(); if (objectid == 1) { world.doEval("addObject(new Wombat(), x, y)"); } else if (objectid == 2) { world.doEval("addObject(new Bird(), x, y)"); } } {noformat}

... and others for uploading and downloading "levels" for an greenfoot-based game.


Issue metadata

  • Issue type: Task
  • Priority: Medium
  • Fix versions: 2.0