Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3978

Can't override destroy method of a sprite (maybe because of Webpack)

$
0
0

Hi!
I'm new to this forum. I've searched a lot, but couldn't find a way to fix my issue.
What I'm trying to do is to override destroy method of the Sprite class.
Here's a code, that I use (TypeScript):

const destroySprite = Sprite.prototype.destroy;
console.log(PIXI.Sprite.prototype, PIXI.Sprite, Sprite.prototype, Sprite, PIXI);
Sprite.prototype.destroy = function (options: any) {
  // doing some extra logic
  destroySprite.call(this, options);
};

But when I debug the application - I see that I can only step into this overridden method from the derived objects (like Text, TilingSprite etc.).
Pixi's version in the package.json is:

"pixi.js": "^5.3.8",

Also I use webpack 5 for modules bundling. I have some suspicion that it may be the source of problems.
And there's a result console.log, that I've added to the code snippet above:
image.png.24c3e65a819656a4abdf3aeec0a8cca5.png
I would be very thankful if someone could give me an advise on how that issue can be fixed.
Thanks in advance.


Viewing all articles
Browse latest Browse all 3978

Trending Articles