Search in sources :

Example 1 with AliveComponent

use of com.almasb.fxgl.entity.component.AliveComponent in project FXGL by AlmasB.

the class ScriptSample method initGame.

@Override
protected void initGame() {
    player = Entities.builder().at(100, 100).viewFromNodeWithBBox(new Rectangle(40, 40, Color.BLUE)).with(new DeveloperWASDControl()).buildAndAttach(getGameWorld());
    enemy = Entities.builder().at(180, 100).viewFromNodeWithBBox(new Rectangle(30, 30, Color.RED)).with(new AliveComponent(true)).with(new ActivatorComponent(), new IDComponent("wanderer", 0)).with("onActivate", "first_script.js").with("onActivate.name", "wanderer").with("onActivate.id", 0).with("onDeath", "second_script.js").with("onRevive", "first_script.js").buildAndAttach(getGameWorld());
    Entities.builder().at(380, 100).viewFromNodeWithBBox(new Rectangle(30, 30, Color.RED)).with(new AliveComponent(true)).with(new ActivatorComponent(), new IDComponent("wanderer", 1)).with("onActivate", "second_script.js").with("onActivate.name", "wanderer").with("onActivate.id", 1).buildAndAttach(getGameWorld());
}
Also used : DeveloperWASDControl(com.almasb.fxgl.devtools.DeveloperWASDControl) Rectangle(javafx.scene.shape.Rectangle) ActivatorComponent(com.almasb.fxgl.entity.component.ActivatorComponent) IDComponent(com.almasb.fxgl.entity.component.IDComponent) AliveComponent(com.almasb.fxgl.entity.component.AliveComponent)

Aggregations

DeveloperWASDControl (com.almasb.fxgl.devtools.DeveloperWASDControl)1 ActivatorComponent (com.almasb.fxgl.entity.component.ActivatorComponent)1 AliveComponent (com.almasb.fxgl.entity.component.AliveComponent)1 IDComponent (com.almasb.fxgl.entity.component.IDComponent)1 Rectangle (javafx.scene.shape.Rectangle)1