use of com.almasb.fxgl.entity.RenderLayer in project FXGL by AlmasB.
the class RenderLayerSample method initGame.
@Override
protected void initGame() {
Entities.builder().at(100, 100).viewFromNode(new Rectangle(40, 40)).buildAndAttach(getGameWorld());
EntityView view = new EntityView(new Rectangle(40, 40, Color.RED));
// 1. predefine or create dynamically like below
RenderLayer layer = new RenderLayer() {
@Override
public String name() {
// 2. specify the unique name for that layer
return "LAYER_BELOW_PLAYER";
}
@Override
public int index() {
// 3. specify layer index, higher values will be drawn above lower values
return 1000;
}
};
// we have added box after player but because of the render layer we specified
// the red box will be drawn below the player
Entities.builder().at(80, 80).viewFromNode(view).renderLayer(layer).buildAndAttach(getGameWorld());
}
Aggregations