Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: class constructors must be invoked with 'new' using Shockwave filter #381

Open
wolfiton opened this issue Apr 3, 2023 · 0 comments

Comments

@wolfiton
Copy link

wolfiton commented Apr 3, 2023

Hello here is the code that reproduces the error from what I understand there is an issue with version 7 of Pixi and the filters plugin. So my question is:
Can this be fixed or I need to use version 6 of Pixi to be able to use the filter in my projects?

const app = new PIXI.Application({
  height: window.innerHeight,
  width: window.innerWidth,
});

document.body.appendChild(app.view);

// create a sprite with an image

  const texture = await PIXI.Assets.load("./assets/images/sunset.jpg");

  // create a new Sprite from the awaited loaded Texture
  const sprite = PIXI.Sprite.from(texture);

  // center the sprite's anchor point
  sprite.anchor.set(0.5);

  // move the sprite to the center of the screen
  sprite.x = app.screen.width / 2;
  sprite.y = app.screen.height / 2;

  app.stage.addChild(sprite);

  // create a new ShockwaveFilter
  const shockwaveFilter = new PIXI.filters.ShockwaveFilter(
    {
      amplitude: 20, // the amplitude of the shockwave effect
      wavelength: 100, // the wavelength of the shockwave effect
      brightness: 1, // the brightness of the shockwave effect
      speed: 500, // the speed of the shockwave effect
    }
  );

  // apply the shockwave filter to the sprite
  sprite.filters = [shockwaveFilter];

  // animate the shockwave filter by updating the center property
  app.ticker.add(() => {
    // update the center of the shockwave filter
    shockwaveFilter.center = [
      sprite.x + sprite.width / 2,
      sprite.y + sprite.height / 2,
    ];
  });

Thank you in advance for your time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant