Jump to content

Extending sprite reduces performance


Recommended Posts


When extending the sprite class and using it instead of adding the default sprite the performance becomes really bad.

// Using this reduces the performance a lot after 5k+ sprites:
class Car extends Sprite {
  constructor() {
    this.texture = Texture.from("/car.png");
    this.interactive = true;
    this.anchor.set(0.5, 0.5);
    //... other manipulation

app.stage.addChild(new Car())

// compared to this (nearly no performance loss even after 50k+ sprites):
function addCar(app) {
  const sprite = new Sprite()
  sprite.texture = Texture.from("/car.png");
  sprite.interactive = true;
  sprite.anchor.set(0.5, 0.5);
  //... other manipulation


What could be the reason for this?

Edited by Galious
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.

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.


  • Recently Browsing   0 members

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