Search in sources :

Example 1 with DraggableComponent

use of com.almasb.fxgl.dsl.components.DraggableComponent in project FXGL by AlmasB.

the class GraphVisSample method makeNode.

private Entity makeNode(int id) {
    var e = entityBuilder().at(FXGLMath.randomPoint(new Rectangle2D(0, 0, getAppWidth(), getAppHeight()))).view(new Circle(NODE_RADIUS, NODE_RADIUS, NODE_RADIUS)).with("id", id).with(new DraggableComponent()).onClick(entity -> {
    // here you can find out more info about the node in question
    }).buildAndAttach();
    nodes.put(id, e);
    return e;
}
Also used : Color(javafx.scene.paint.Color) Rectangle2D(javafx.geometry.Rectangle2D) FXGLMath(com.almasb.fxgl.core.math.FXGLMath) HashMap(java.util.HashMap) Line(javafx.scene.shape.Line) List(java.util.List) Map(java.util.Map) GameSettings(com.almasb.fxgl.app.GameSettings) DraggableComponent(com.almasb.fxgl.dsl.components.DraggableComponent) Circle(javafx.scene.shape.Circle) GameApplication(com.almasb.fxgl.app.GameApplication) Entity(com.almasb.fxgl.entity.Entity) FXGL(com.almasb.fxgl.dsl.FXGL) Circle(javafx.scene.shape.Circle) Rectangle2D(javafx.geometry.Rectangle2D) DraggableComponent(com.almasb.fxgl.dsl.components.DraggableComponent)

Aggregations

GameApplication (com.almasb.fxgl.app.GameApplication)1 GameSettings (com.almasb.fxgl.app.GameSettings)1 FXGLMath (com.almasb.fxgl.core.math.FXGLMath)1 FXGL (com.almasb.fxgl.dsl.FXGL)1 DraggableComponent (com.almasb.fxgl.dsl.components.DraggableComponent)1 Entity (com.almasb.fxgl.entity.Entity)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Rectangle2D (javafx.geometry.Rectangle2D)1 Color (javafx.scene.paint.Color)1 Circle (javafx.scene.shape.Circle)1 Line (javafx.scene.shape.Line)1