Reputation: 309
How to create a tile based game map in javafx 2.0?
Should I use ImageView elements or there is other method for direct images drawing?
Upvotes: 0
Views: 2507
Reputation: 4352
Your question is not very specific.
As I understand your issue a possible option is to extend a javafx.scene.layout.Region. So you are free to add other nodes, make some custom drawings, style with css etc. Nearly everything is possible :)
Example Code (Sorry, no SSCCE)
public class Tile extends Region {
public Tile() {
//add custom creation code
}
//add all required methods for custom drawing, styling etc.
}
Tiles can be placed inside a e.g. TileContainer (another Object extending e.g. a Region) at a specified position (described by x/y-coordinates).
public class TileContainer extends Region {
private void addTiles() {
//create your tiles e.g. like this
double xPositon = 10; //example value
double yPosition = 20; //example value
Tile tile = new Tile();
tile.setLayoutX(xPosition);
tile.setLayoutY(yPOsition);
this.getChildren.add(tile);
}
}
Hope, it helps realizing your ideas.
Upvotes: 1