Jump to content

How to execute every second?


RayXu
 Share

Recommended Posts

Welcome to the forums!

"1 / 60 * delta" or "ticker.deltaMs" https://github.com/pixijs/pixi.js/blob/3ffe52d29aedd79a5a281b4a6032e7c95f5ea98c/packages/ticker/src/Ticker.ts#L493

PixiJs does not have a scheduler, only a basic ticker for RAF.

Here's scheduler in a plugin https://github.com/Nazariglez/pixi-timer/ As far as I remember, its detached from PixiJS enough to work with anything >3.0.8 , even with v5. In case you use modern es6 modules, you  PIXI in global scope for it to work (like for other pixi vanilla modules, https://github.com/pixijs/pixi-layers#webpack-browserify-angular )

As usual, explanation why dont we have those functions in main package: we really care about size of our packages and dont want to force users on using our API's for trivial things. We provide renderer expertise.

Edited by ivan.popelyshev
Link to comment
Share on other sites

Thx :)

oh...Turned out to be used...

"1 / 60 * delta" or "ticker.deltaMs"

This can do what I want! Now I use the following code instead.

He should be fine.

const seconds = 0;
app.ticker.add(delta => {
  seconds += (1 / 60) * delta;
  if(seconds >= 0.5 ){
    console.log('alert!');
  }
});

but...pixi-timer I don’t understand how to use?

Because I will update the screen through time judgment during recycling.

Finally thank you @ivan.popelyshev :D

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...