Jump to content

Application.start() vs.ticker.add()


Majirefy
 Share

Recommended Posts

As PixiJS introduced Application class, I find there is a function start():

Quote

Convenience method for starting the render.

In PixiJS examples, the game loop always starts like:

// Animate the rotation
app.ticker.add(function() {
    anim.rotation += 0.01;
});

But some examples use app.start().

So what is the best way for game loop? requestAnimateFrame? app.ticker.add? app.start?

Link to comment
Share on other sites

The constructor for Application calls this.start() so you don't need to manually call start() unless you call stop()

For example maybe you want to wait to start rendering until all of your resources are done loading and all of your sprites are on the stage. So you can create the Application and call stop(), then create and add-to-stage your sprites as the resources become available, then call start() when everything's done loading.

Link to comment
Share on other sites

5 hours ago, Jinz said:

The constructor for Application calls this.start() so you don't need to manually call start() unless you call stop()

For example maybe you want to wait to start rendering until all of your resources are done loading and all of your sprites are on the stage. So you can create the Application and call stop(), then create and add-to-stage your sprites as the resources become available, then call start() when everything's done loading.

So it's better to use app.ticker.add to make game loop? Or just use requestAnimateFrame?

Link to comment
Share on other sites

1 hour ago, Majirefy said:

So it's better to use app.ticker.add to make game loop? Or just use requestAnimateFrame?

Application takes care of lot for you but if you want to do it yourself then you can create the renderer and stage and call requestAnimationFrame() and render() and calculate delta for animations all yourself, instead of creating the Application and adding your animation function to it's ticker. So I'd just use the Application class unless there's a need to handle these things differently than it does...

Link to comment
Share on other sites

  • 4 years later...

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...