下面列出了怎么用javafx.scene.effect.Bloom的API类实例代码及写法,或者点击链接到github查看源代码。
@Spawns("Laser")
public Entity newLaser(SpawnData data) {
Entity owner = data.get("owner");
Texture t = texture("laser2.png");
t.relocate(-2, -20);
t.setEffect(new Bloom(0.5));
return entityBuilder()
.type(BULLET)
.at(owner.getCenter().add(-4.5, -20))
.bbox(new HitBox(BoundingShape.box(9, 20)))
.view(t)
.with(new CollidableComponent(true), new OwnerComponent(owner.getType()))
.with(new OffscreenCleanComponent(), new BulletComponent(850))
.build();
}
protected void onMousePress(MouseEvent event) {
pressed = (Node) event.getTarget();
System.out.println("press " + pressed);
startMousePosition = new Point2D(event.getSceneX(), event.getSceneY());
startLayoutPosition = new Point2D(pressed.getLayoutX(),
pressed.getLayoutY());
// add effect
pressed.setEffect(new Bloom(0));
IAnchor ifxAnchor = anchors.get(pressed);
if (ifxAnchor != null) {
Set<AnchorKey> keys = ifxAnchor.positionsUnmodifiableProperty()
.keySet();
for (AnchorKey key : keys) {
key.getAnchored().setEffect(null);
}
}
}
@Spawns("Laser")
public Entity newLaser(SpawnData data) {
Entity owner = data.get("owner");
Texture t = texture("laser2.png");
t.relocate(-2, -20);
t.setEffect(new Bloom(0.5));
return entityBuilder()
.type(BULLET)
.at(owner.getCenter().add(-4.5, -20))
.bbox(new HitBox(BoundingShape.box(9, 20)))
.view(t)
.with(new CollidableComponent(true), new OwnerComponent(owner.getType()))
.with(new OffscreenCleanComponent(), new BulletComponent(850))
.build();
}
public CoinHighlightViewComponent() {
super(5, 5);
Rectangle rect = new Rectangle(30, 30, Color.color(0.8, 0, 0, 0.9));
rect.setArcWidth(15);
rect.setArcHeight(15);
rect.setEffect(new Bloom(0.9));
getViewRoot().getChildren().add(rect);
}
public CoinHighlightViewComponent() {
super(5, 5);
Rectangle rect = new Rectangle(30, 30, Color.color(0.8, 0, 0, 0.9));
rect.setArcWidth(15);
rect.setArcHeight(15);
rect.setEffect(new Bloom(0.9));
getViewRoot().getChildren().add(rect);
}