1.0.6 • Published 6 months ago

parseq-tasks v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

###Manage nested tasks in Parallel or in Sequence.

The tasks' update dt (delta time) is managed in seconds.

const TICK = 1 / 60;
const TASK = new Parallel();
const POINT = {x: 0, y: 0};

setInterval(() => {
    TASK.update(TICK);
}, TICK * 1000);

TASK.add(new Sequence(
    new Excecute(() => { console.log("1") }),
    new Wait(1),
    new Excecute(() => { console.log("2") }),
    new Wait(1),
    new Parallel(
        new Excecute(() => { console.log("3") }),
        new Excecute(() => { console.log("4") }),
        new Ease(2, POINT, {x: 2}),
        new Ease(2, POINT, {y: 3}),
    ),
    new Excecute(() => { console.log(POINT) }),
    new Wait(1),
    new Excecute(() => { console.log("5") }),
));

Extend from the Task class to develop your custom tasks.

export class ImageLoader extends Task {
    constructor(url) {
        super();
        this.start = false;
        this.url = url;
        this.image = null;
    }

    update(dt) {
        if (this.start === false) {
            this.start = true;
            this.image = new Image();
            this.image.src = this.url;
            this.image.onload = () => {
                this.done = true;
            };
        }
    }
}
1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago