Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

22 Commits

Repository files navigation

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

importlitecanvasfrom"litecanvas"importpluginTimersfrom"@litecanvas/plugin-timers"litecanvas({loop: { init },})use(pluginTimers)// load the pluginfunctioninit(){wait(5,()=>{// this function will be executed after 5 seconds})loop(2,()=>{// this function will be executed every 2 seconds})repeat(10,2,()=>{// this function will be executed only 10 times every 2 seconds})}

Other features

Available for any kind of timer

Stop a timer:

constt=wait(5,()=>{// ...})t.stop()// cancel the timer

Pause a timer:

constt=wait(5,()=>{// ...})t.pause()// pause the timert.resume()// resume a paused timert.running// true if the timer is not paused

Get/set the remaining time:

constt=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 variableTIMERS.forEach((t)=>{// ...})

About

⏰ Plugin to help manage timers in litecanvas games

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Used by

Contributors

Languages