30.09 ptp
This commit is contained in:
30
Chip.~ava
30
Chip.~ava
@@ -1,6 +1,9 @@
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.shape.Shape;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.event.Event;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
/**
|
||||
*
|
||||
* Beschreibung
|
||||
@@ -10,6 +13,7 @@ import javafx.scene.shape.Circle;
|
||||
*/
|
||||
|
||||
public class Chip {
|
||||
public Game game;
|
||||
|
||||
public Color color;
|
||||
|
||||
@@ -24,7 +28,7 @@ public class Chip {
|
||||
|
||||
public Circle circle;
|
||||
|
||||
public Chip(relX,relY,absX,absY, Color color) {
|
||||
public Chip(int relX, int relY,double absX, double absY, Color color, Game game) {
|
||||
relativeX = relX;
|
||||
relativeY = relY;
|
||||
|
||||
@@ -35,11 +39,33 @@ public class Chip {
|
||||
|
||||
radius = 20;
|
||||
|
||||
circle = new Circle(absoluteX,absoluteY,radius);
|
||||
this.color = color;
|
||||
circle = new Circle(absoluteX, absoluteY, radius);
|
||||
circle.setFill(this.color);
|
||||
|
||||
this.game = game;
|
||||
circle.addEventHandler(MouseEvent.MOUSE_CLICKED, mouse_clicked);
|
||||
|
||||
}
|
||||
public void setPositionX(double X) {
|
||||
absoluteX = X;
|
||||
circle.setCenterX(absoluteX);
|
||||
}
|
||||
public void setPositionY(double Y) {
|
||||
absoluteX = Y;
|
||||
circle.setCenterX(absoluteY);
|
||||
}
|
||||
public Shape getShape() {
|
||||
return circle;
|
||||
|
||||
}
|
||||
EventHandler<MouseEvent> mouse_clicked = new EventHandler<MouseEvent>() {
|
||||
public void handle(MouseEvent handle) {
|
||||
chip_clicked();
|
||||
}
|
||||
|
||||
};
|
||||
public void chip_clicked() {
|
||||
game.chip_clicked(this);
|
||||
}
|
||||
} // end of Chip
|
||||
|
||||
Reference in New Issue
Block a user