Search in sources :

Example 1 with Texture

use of com.almasb.fxgl.texture.Texture in project FXGL by AlmasB.

the class QuadSample method onUpdate.

@Override
protected void onUpdate(double tpf) {
    Texture t = originals.get(j);
    t.setImage(textures2.get(j).getImage());
    if (j > 0) {
        originals.get(j - 1).setImage(textures.get(j - 1).getImage());
    }
    j++;
    if (j == 10) {
        j = 0;
    }
}
Also used : Texture(com.almasb.fxgl.texture.Texture)

Example 2 with Texture

use of com.almasb.fxgl.texture.Texture in project FXGL by AlmasB.

the class BasicGameApp2 method initUI.

@Override
protected void initUI() {
    Text textPixels = new Text();
    // x = 50
    textPixels.setTranslateX(50);
    // y = 100
    textPixels.setTranslateY(100);
    textPixels.textProperty().bind(getGameState().intProperty("pixelsMoved").asString());
    // add to the scene graph
    getGameScene().addUINode(textPixels);
    Texture brickTexture = getAssetLoader().loadTexture("brick.png");
    brickTexture.setTranslateX(50);
    brickTexture.setTranslateY(450);
    getGameScene().addUINode(brickTexture);
}
Also used : Text(javafx.scene.text.Text) Texture(com.almasb.fxgl.texture.Texture)

Example 3 with Texture

use of com.almasb.fxgl.texture.Texture in project FXGL by AlmasB.

the class BasicGameApp3 method initUI.

@Override
protected void initUI() {
    Text textPixels = new Text();
    // x = 50
    textPixels.setTranslateX(50);
    // y = 100
    textPixels.setTranslateY(100);
    textPixels.textProperty().bind(getGameState().intProperty("pixelsMoved").asString());
    // add to the scene graph
    getGameScene().addUINode(textPixels);
    Texture brickTexture = getAssetLoader().loadTexture("brick.png");
    brickTexture.setTranslateX(50);
    brickTexture.setTranslateY(450);
    getGameScene().addUINode(brickTexture);
}
Also used : Text(javafx.scene.text.Text) Texture(com.almasb.fxgl.texture.Texture)

Example 4 with Texture

use of com.almasb.fxgl.texture.Texture in project FXGL by AlmasB.

the class InterpolatorSample2 method initGame.

@Override
protected void initGame() {
    int i = 0;
    for (Interpolators interpolator : Interpolators.values()) {
        Text t = getUIFactory().newText(interpolator.toString() + ":");
        t.setFill(Color.BLACK);
        Pane p = new Pane(t);
        p.setTranslateY(i * 50 + 25);
        Line line = new Line(0, i * 50, getWidth(), i * 50);
        line.setStroke(Color.RED);
        getGameScene().addUINodes(p, line);
        Texture texture = DSLKt.texture("bird.png").toAnimatedTexture(2, Duration.seconds(0.5));
        Entity bird = Entities.builder().at(100, i * 50).viewFromNode(texture).buildAndAttach();
        Entities.animationBuilder().interpolator(interpolator.EASE_OUT()).duration(Duration.seconds(2)).repeatInfinitely().translate(bird).from(new Point2D(100, i * 50)).to(new Point2D(400, i * 50)).buildAndPlay();
        i++;
    }
}
Also used : Line(javafx.scene.shape.Line) Entity(com.almasb.fxgl.entity.Entity) Point2D(javafx.geometry.Point2D) Interpolators(com.almasb.fxgl.animation.Interpolators) Text(javafx.scene.text.Text) Pane(javafx.scene.layout.Pane) Texture(com.almasb.fxgl.texture.Texture)

Example 5 with Texture

use of com.almasb.fxgl.texture.Texture in project FXGL by AlmasB.

the class AssetsSample method approach1.

private void approach1() {
    // load texture
    Texture brickTexture = getAssetLoader().loadTexture("brick.png");
    Entity brick = new Entity();
    brick.setPosition(100, 300);
    // set texture as main view
    brick.setView(brickTexture);
    getGameWorld().addEntity(brick);
}
Also used : Entity(com.almasb.fxgl.entity.Entity) Texture(com.almasb.fxgl.texture.Texture)

Aggregations

Texture (com.almasb.fxgl.texture.Texture)10 Text (javafx.scene.text.Text)4 WritableImage (javafx.scene.image.WritableImage)3 HeightMapGenerator (com.almasb.fxgl.algorithm.procedural.HeightMapGenerator)2 Entity (com.almasb.fxgl.entity.Entity)2 BiomeMapGenerator (com.almasb.fxgl.algorithm.procedural.BiomeMapGenerator)1 AnimatedColor (com.almasb.fxgl.animation.AnimatedColor)1 Interpolators (com.almasb.fxgl.animation.Interpolators)1 EntityView (com.almasb.fxgl.entity.view.EntityView)1 Point2D (javafx.geometry.Point2D)1 Rectangle2D (javafx.geometry.Rectangle2D)1 HBox (javafx.scene.layout.HBox)1 Pane (javafx.scene.layout.Pane)1 LinearGradient (javafx.scene.paint.LinearGradient)1 Stop (javafx.scene.paint.Stop)1 Line (javafx.scene.shape.Line)1 Rectangle (javafx.scene.shape.Rectangle)1