Javascript 为什么继承的类比pixi.js上的实际sprite对象慢?

Javascript 为什么继承的类比pixi.js上的实际sprite对象慢?,javascript,pixi.js,Javascript,Pixi.js,我用两种不同的方法向容器中添加了10000个sprite对象 首先,我使用了扩展的sprite类 import { Application, Container, Texture, Sprite } from "pixi.js"; ... ... ... class Bunny extends Sprite { constructor() { super(texture); this.angle = ((Math.random() * Math.PI) /

我用两种不同的方法向容器中添加了10000个sprite对象

首先,我使用了扩展的sprite类

import { Application, Container, Texture, Sprite } from "pixi.js";
...
...
...


class Bunny extends Sprite {
constructor() {
    super(texture);
    this.angle = ((Math.random() * Math.PI) / 180) * 360;
    this.l = Math.random();
    this.x = app.renderer.width * 0.5;
    this.y = app.renderer.height * 0.5;
    this.hx = Math.cos(this.angle) * this.l;
    this.hy = Math.sin(this.angle) * this.l;
    this.scale.set(.5);
    this.anchor.set(0.5);

}
update() {
    this.x += this.hx;
    this.y += this.hy;
    }
}
然后我使用了标准精灵对象

const bunny = new Sprite(texture);
const angle = ((Math.random() * Math.PI) / 180) * 360;
bunny.l = Math.random();
bunny.hx = Math.cos(angle) * bunny.l;
bunny.hy = Math.sin(angle) * bunny.l;
bunny.rotation = angle;
bunny.anchor.set(0.5);
bunny.tint = Math.random() * 0xffffff;
bunny.x = app.renderer.width * 0.5;
bunny.y = app.renderer.height * 0.5;
bunny.scale.set(0.5);
当我使用扩展的精灵类(兔子对象)时,它的速度比实际的精灵对象慢了近六倍(10-11fps)。 为什么会这样


有没有办法避免这种情况?

那么您如何使用这两个对象呢?无论如何,这可能是Javscript(不是特定于pixi.js)中的问题:那么如何使用这两个对象呢?无论如何,这可能是Javscript中的问题(不是特定于pixi.js):