use of com.almasb.fxgl.entity.action.ActionComponent in project FXGL by AlmasB.
the class EntityActionSample method initGame.
@Override
protected void initGame() {
getGameScene().setBackgroundColor(Color.LIGHTGRAY);
mover = entityBuilder().at(400, 20).viewWithBBox(texture("player2rot.png").multiplyColor(Color.RED)).with(new ProjectileComponent(new Point2D(0, 1), 200)).onClick(e -> {
entity.getComponent(ActionComponent.class).addAction(new FollowAction(mover));
}).buildAndAttach();
mover2 = entityBuilder().at(500, 200).viewWithBBox(texture("player2rot.png").multiplyColor(Color.BLUE)).with(new ProjectileComponent(new Point2D(1, 0), 250)).onClick(e -> {
entity.getComponent(ActionComponent.class).addAction(new FollowAction(mover2));
}).buildAndAttach();
entity = entityBuilder().at(400, 300).viewWithBBox("player2rot.png").with(new ActionComponent()).with(new FollowComponent(null, 150, 40, 100)).with(new FixRotateComponent()).buildAndAttach();
unit = entityBuilder().at(700, 400).viewWithBBox(new Rectangle(40, 40, Color.GREEN)).with(new FollowComponent(null, 100, 30, 50)).onClick(e -> {
entity.getComponent(ActionComponent.class).addAction(new RecruitAction(unit));
}).buildAndAttach();
// unit2 = entityBuilder()
// .at(700, 200)
// .view(new Rectangle(40, 40, Color.GREEN))
// .with(new FollowComponent(null, 50, 60, 130))
// .onClick(() -> {
// entity.getComponent(ActionComponent.class)
// .addAction(new RecruitAction(unit2));
// })
// .buildAndAttach();
}
Aggregations