This site requires JavaScript, please enable it in your browser!
Greenfoot back
Wasupmacuz
Wasupmacuz wrote ...

2019/6/8

Updating Fullscreen Project

Wasupmacuz Wasupmacuz

2019/6/8

#
I'm sure a lot of the OG's here remember that project back in (I think) 2013 that would automatically convert your greenfoot projects to fullscreen. Currently, I'm trying to update the code. I got all the basic stuff done, like changing java.awt.Color to greenfoot.Color. I also changed the line
1
BufferedImage bgImage = WorldHandler.getInstance().getSnapShot();
to
1
2
3
4
5
6
7
GreenfootImage main = new GreenfootImage(getBackground());
for (Object obj : getObjects(null))
{
    Actor actor = (Actor) obj;
    main.drawImage(actor.getImage(), actor.getX()-actor.getImage().getWidth()/2, actor.getY()-actor.getImage().getHeight()/2);
}
BufferedImage bgImage = main.getAwtImage();
Since there's no getSnapShot method anymore. At this point, if I comment out all the other errors, it's go fullscreen nicely...until I change worlds. The other errors that I'm stumped on are 1)
1
greenfoot.gui.GreenfootFrame
and 2)
1
WorldHandler.getInstance().getWorldCanvas();
1) Apparently, GreenfootFrame was a subclass of java.awt.Window(?) javax.swing.JFrame. What's the equivalent to GreenfootFrame now? What Greenfoot class displays the window? 2) I'm not even sure what the WorldCanvas even did. It sounds like it would be the same as getSnapShot(), but apparently the method returned a java.awt.Component. Edit: it was a subclass of a javax.swing.JPanel. I'm not sure if what I'm doing is in vain or not. Maybe Dan might have a clue ;)
Super_Hippo Super_Hippo

2019/6/8

#
(Unfortunately I don't really have a clue, only a small note: The Actor's images need to be rotated to the Actor's rotation before drawing them on the main image. And also, with writing here, I enable the notifications for this discussion, because it is an interesting topic I don't want to miss out.)
Wasupmacuz Wasupmacuz

2019/6/8

#
Super_Hippo wrote...
The Actor's images need to be rotated to the Actor's rotation before drawing them on the main image.
That's a very good point! Do you think getObjects(null) would sort the list based on the paint order? otherwise, I'd have to do that manually as well.
Wasupmacuz Wasupmacuz

2019/6/8

#
I just found that greenfoot.guifx.WorldDisplay has a public Image getSnapshot() method! It's drawing near 5am, I'll look into the possibilities of using this in the morning.
nccb nccb

2019/6/8

#
In recent versions of Greenfoot, the user code runs in a different process to the main window, so I'm afraid in the IDE there's literally no way (or even a hack) to make it go full screen without modifying Greenfoot. The standalone export is probably a better bet if you're really determined. The following hack looks like it works if you put it in an override of World.started() (note: this will apply in standalone only):
1
2
3
4
javafx.application.Platform.runLater(() -> {
    if (javafx.stage.Window.getWindows().size() > 0)
        ((javafx.stage.Stage)javafx.stage.Window.getWindows().get(0)).setFullScreen(true);
});
Wasupmacuz Wasupmacuz

2019/6/8

#
nccb wrote...
there's literally no way (or even a hack) to make it go full screen without modifying Greenfoot.
Aw, shucks. I was looking forward to getting it to work. Thanks for the help!
Wasupmacuz Wasupmacuz

2019/6/8

#
Do you know why that block of code only works in standalone? is getWindows() an exclusive method? Edit: I tried this in the standalone and I get the same error as the windows version cannot find symbol getWindows() It looks like java.awt.Window has getWindows() which returns an array of Windows, but javafx.stage.Window does not have a method that returns a List of Windows. Edit 2: I found that JavaFX 11's Window has getWindows(), but JavaFX 8's does not.
nccb nccb

2019/6/9

#
Ah yes, sorry I forgot that it was a Java 11 method. We're currently testing Greenfoot 3.6.0 which will be based on Java 11, which should be out in a week or two.
Wasupmacuz Wasupmacuz

2019/6/10

#
nccb wrote...
Ah yes, sorry I forgot that it was a Java 11 method. We're currently testing Greenfoot 3.6.0 which will be based on Java 11, which should be out in a week or two.
Oh, okay. Thanks for the info!
You need to login to post a reply.