0.7.0 • Published 9 months ago

@litecanvas/plugin-timers v0.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

Timers plugin for litecanvas

Helpers to manage timers in litecanvas games.

Install

NPM: npm i @litecanvas/plugin-timers

CDN: https://unpkg.com/@litecanvas/plugin-timers/dist/dist.js

Usage

import litecanvas from "litecanvas"
import pluginTimers from "@litecanvas/plugin-timers"

litecanvas({
  loop: { init },
})

use(pluginTimers) // load the plugin

function init() {
  wait(5, () => {
    // this function will be executed after 5 seconds
  })

  repeat(10, 2, () => {
    // this function will be executed 10 times every 2 seconds
  })
}

Other features

Stop a timer:

const t = wait(5, () => {
  // ...
})

t.stop() // cancel the timer

Pause a timer:

const t = wait(5, () => {
  // ...
})

t.pause() // pause the timer

t.resume() // resume a paused timer

t.running // true if the timer is not paused

Get/set the remaining time:

const t = wait(5, () => {
  // ...
})

t.remaining += 10 // add 10 seconds

Get all active timers:

...
litecanvas()

use(pluginTimers, {
  exposeTimers: true // enable that settings
})

// now you can use the TIMERS variable
TIMERS.forEach((t) => {
  // ...
})
0.7.0

9 months ago

0.6.0

9 months ago

0.5.0

10 months ago

0.3.2

12 months ago

0.4.0

12 months ago

0.3.3

12 months ago

0.3.1

1 year ago

0.3.0

1 year ago

0.2.0

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago