Test Implementierung mit JavaFX
parent
f14926f1ff
commit
418535c89c
@ -1,5 +1,26 @@
|
||||
|
||||
package greenfootReplacement;
|
||||
|
||||
import javafx.scene.image.ImageView;
|
||||
|
||||
public class Actor {
|
||||
|
||||
|
||||
GreenfootImage image = null;
|
||||
|
||||
private static javafx.scene.image.Image getFXImage() throws java.io.IOException {
|
||||
java.awt.image.BufferedImage i = image.getAwtImage();
|
||||
if (!(image instanceof java.awt.image.RenderedImage)) {
|
||||
java.awt.image.BufferedImage bufferedImage = new java.awt.image.BufferedImage(image.getWidth(null), image.getHeight(null), java.awt.image.BufferedImage.TYPE_INT_ARGB);
|
||||
java.awt.Graphics g = bufferedImage.createGraphics();
|
||||
g.drawImage(image, 0, 0, null);
|
||||
g.dispose();
|
||||
image = bufferedImage;
|
||||
}
|
||||
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
|
||||
javax.imageio.ImageIO.write((java.awt.image.RenderedImage) image, "png", out);
|
||||
out.flush();
|
||||
java.io.ByteArrayInputStream in = new java.io.ByteArrayInputStream(out.toByteArray());
|
||||
return new javafx.scene.image.Image(in);
|
||||
}
|
||||
|
||||
}
|
@ -1,18 +1,36 @@
|
||||
|
||||
package greenfootReplacement;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
/**
|
||||
Ersetzt die Greenfoot Klasse von Greenfoot und hält das Programm am Laufen.
|
||||
*/
|
||||
public class Greenfoot {
|
||||
public class Greenfoot extends Application {
|
||||
|
||||
private Stage mainStage = null;
|
||||
|
||||
private static World currentWorld = null;
|
||||
private World currentWorld = null;
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
|
||||
@Override public void start(Stage primaryStage) throws Exception {
|
||||
mainStage = primaryStage;
|
||||
mainStage.setTitle("Zweiundvierzig - Greenfoot as JavaFX");
|
||||
setWorld(new Start_Load());
|
||||
mainStage.show();
|
||||
}
|
||||
|
||||
public static void setWorld(World w) {
|
||||
|
||||
currentWorld = w;
|
||||
mainStage.setScene(currentWorld);
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,22 @@
|
||||
|
||||
package greenfootReplacement;
|
||||
|
||||
public class World {
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
public abstract class World extends Scene {
|
||||
|
||||
AnchorPane layout = null;
|
||||
|
||||
public World(int width, int height, int cellSize) {
|
||||
super(new AnchorPane(), width * cellSize, height * cellSize);
|
||||
|
||||
}
|
||||
|
||||
public void act();
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue