import { Text } from "pixi.js";

export class TimerDisplay {
    /*  variable callback should be a callback giving the value to display */
    constructor(variableCallback, ticker) {
        this.node = new Text({
            text: "default text",
            style: {
                fontFamily: "Arial",
                fontSize: 24,
                fill: 0xff1010,
                align: "center",
            },
        });

        this.variableCallback = variableCallback;
        this.callback = () => {
            this.node.text = "" + this.variableCallback();
        };
        this.ticker = ticker;
    }

    start() {
        this.ticker.add(this.callback);
    }

    stop() {
        this.ticker.remove(this.callback);
    }
}
