Jump to content

Performance overhead of PIXI.Container


Aroxis
 Share

Recommended Posts

Hello!

I was wondering if `PIXI.Containers` have any associated performance overhead.

Take the following examples:

Example #1: Extending Container:

class SpriteTile extends PIXI.Container {
  constructor(resource) {
    super();

    // Create a sprite and add it to children
    const sprite = new PIXI.Sprite.fromImage(resource);
    this.addChild(sprite);
  }

}

Example #2: Extending Sprite directly: 

class SpriteTile extends PIXI.Sprite {
  constructor(resource) {
    super(resource);
  }

}

Both examples achieve the same thing.

Example #1, while seemingly more obscure, keeps a certain level of extensibility by having the freedom of a Container.

Example #2 is much more direct but is now also limited to the functionality of a simple Sprite.

My question being; is there any (notable?) performance benefit over choosing example #2 over #1 in the use cases as shown above?

Thanks in advance!

 

Link to comment
Share on other sites

28 minutes ago, ivan.popelyshev said:

So, 5000 tiles of #2 will eat same amount of CPU as 10000 of #1 in updateTransform() loop.

#2 renders just the Sprite while #1 renders both the Container and the Sprite, so it's the other way around, right?

But what I gather is that both ways are fine because they can handle much more than the usual use case. Thanks!

Link to comment
Share on other sites

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