javafx를 사용하여 간단한 RPG 게임을 만들려고합니다. 지금까지, 나는 화면에 나타나고, 움직이고, 장애물에 부딪치지 않을 나의 성격을 얻었다. 나는 그리드 역할을하는 보드 클래스를 사용하여이 작업을 수행했습니다Javafx가 게임 캐릭터를 따름
public class TestBoard extends Pane{
public static final int TILE_SIZE = 40;
public static final int X_DIM_TILES = 10;
public static final int Y_DIM_TILES = 10;
private Image TREE = new Image(Game.class.getResource("tree.png").toString());
private Image GRASS = new Image(Game.class.getResource("grasssquare.png").toString());
private Character character;
private GameTile[][] tiles = new GameTile[X_DIM_TILES][Y_DIM_TILES];
public TestBoard(){
this.setPrefWidth(TILE_SIZE * X_DIM_TILES);
this.setPrefHeight(TILE_SIZE * Y_DIM_TILES);
setUpScreen();
character = new Character(this);
addCharacter();
}
public boolean checkTile(double x, double y){
return (x < X_DIM_TILES && x >= 0 && y < Y_DIM_TILES && y >= 0 && tiles[(int)x][(int)y].getPassable());
}
public Character getCharacter(){
return character;
}
public void addCharacter(){
character.setLocation(4, 4);
}
public GameTile getTile(int x, int y){
return tiles[x][y];
}
public void setUpScreen(){
for (int i = 0; i < X_DIM_TILES; i++){
for (int j = 0; j < Y_DIM_TILES; j++){
addTile(i, j, GRASS, true);
}
}
for (int j = 1; j < Y_DIM_TILES-1; j++){
addTile(1, j, TREE, false);
}
}
public void addTile(int xCord, int yCord, Image image, boolean passable){
SceneryTile tile = new SceneryTile(this, image, passable);
tile.setLocation(xCord, yCord);
tiles[xCord][yCord] = tile;
}
}
기본적으로,이 클래스는 GameTiles의 컬렉션을 보유하고 문자 개체가 있습니다. 그것은 잘 설정된 방식으로 작동하지만, 실제 RPG처럼 전체 화면을 보여주지 않고 내 주인공 만 표시하도록합니다. 현재 전체 화면이 나타납니다. 내 캐릭터와 함께 화면을 움직이고 전체 화면을 드러내지 못하게하고 싶습니다. 더 많은 문서가 필요한 경우
public void start(Stage primaryStage) throws Exception {
board = new TestBoard();
testManager = new TestManager(this, board);
Scene scene = new Scene(board);
primaryStage.setScene(scene);
primaryStage.show();
setUpAnimation();
setUpKeyPresses();
}

은 알려 주시기 바랍니다! 감사.
그냥 약간의 조언 java.lang 패키지의 Java 표준 클래스를 사용합니다. 캐릭터가 그 중 하나입니다. – Mordechai
[JavaFX에서 타일 엔진 작성하기] (https://www.javacodegeeks.com/2013/01/writing-a-tile-engine-in-javafx.html) (슈퍼 짜증나는 팝업을주의하십시오) 및 [FXGameEngine] (https://github.com/eppleton/FXGameEngine). – jewelsea
@ jewelsea 내가 이것을 더 빨리 보았 더라면 좋겠다. 고맙습니다! – user7356447