Java Code Examples for javafx.scene.Node#getTranslateX()

The following examples show how to use javafx.scene.Node#getTranslateX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Main.java    From FXTutorials with MIT License 6 votes vote down vote up
private void movePlayerX(int value) {
    boolean movingRight = value > 0;

    for (int i = 0; i < Math.abs(value); i++) {
        for (Node platform : platforms) {
            if (player.getBoundsInParent().intersects(platform.getBoundsInParent())) {
                if (movingRight) {
                    if (player.getTranslateX() + config.getPlayerSize() == platform.getTranslateX()) {
                        return;
                    }
                }
                else {
                    if (player.getTranslateX() == platform.getTranslateX() + config.getBlockSize()) {
                        return;
                    }
                }
            }
        }
        player.setTranslateX(player.getTranslateX() + (movingRight ? 1 : -1));
    }
}
 
Example 2
Source File: Main.java    From FXTutorials with MIT License 6 votes vote down vote up
private void movePlayerX(int value) {
    boolean movingRight = value > 0;

    for (int i = 0; i < Math.abs(value); i++) {
        for (Node platform : platforms) {
            if (player.getBoundsInParent().intersects(platform.getBoundsInParent())) {
                if (movingRight) {
                    if (player.getTranslateX() + 40 == platform.getTranslateX()) {
                        return;
                    }
                }
                else {
                    if (player.getTranslateX() == platform.getTranslateX() + 60) {
                        return;
                    }
                }
            }
        }
        player.setTranslateX(player.getTranslateX() + (movingRight ? 1 : -1));
    }
}
 
Example 3
Source File: XYChartUtils.java    From chart-fx with Apache License 2.0 4 votes vote down vote up
public static double getLocationX(final Node node) {
    return node.getLayoutX() + node.getTranslateX();
}