在JavaFX中使用物理引擎JBox2D (三)

2014-11-24 11:33:11 · 作者: · 浏览: 31
Scene scene = new Scene(root, WIDTH, HEIGHT);

primaryStage.setTitle("JavaFX中JBox2D的使用");
primaryStage.setScene(scene);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);
}
}

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MainClass extends Application {
private static final int WIDTH = 800;
private static final int HEIGHT = 600;

@Override
public void start(Stage primaryStage) {
CanvasScreen mCanvas = new CanvasScreen(WIDTH, HEIGHT);
Group root = new Group();
root.getChildren().add(mCanvas);
Scene scene = new Scene(root, WIDTH, HEIGHT);

primaryStage.setTitle("JavaFX中JBox2D的使用");
primaryStage.setScene(scene);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);
}
}


大家可以看看运行效果。

点击


本人使用的是JDK7,大家看提示下载吧。

效果图:

\