I have two game objects that are rectangles, a Player and an Enemy. I want the player to jump on the Y axis and the Enemy to slide along the X axis. When the Player's X,Y position match the Enemy's it should kill the Player. So far, I can't get the AnimationTimer() to check every frame for the constant X position and Y position. It only checks when the application first starts and keeps those values.
How do I get it to check every frame for the X position and Y position of the two rectangles?
AnimationTimer animator = new AnimationTimer() {
public void handle(long arg0) {
//update
double playX = player.getX(), enemX = enemy.getX();
double playY = player.getY(), enemY = enemy.getY();
System.out.println("Player's X: "+ playX + "\n" + "Enemy's X: " + enemX);
System.out.println("Player's Y: "+ playY);
if (playX == enemX && playY == enemY){
System.out.println("Player has Collided with Enemy");
}
}//handle
};
animator.start();//animation