每当我去扩展PIXI.Graphics类时,它会给我一个错误,说关键字“super”是意外的,使用此代码
class Block extends PIXI.Graphics{
construtor(x=0, y=0, width=50, height=50, color=0xFF0000, border=0, borderColor=0xFFFF00){
super();
this.beginFill(color);
this.lineStyle(border, borderColor, 1);
this.drawRect(0, 0, width, height);
this.endFill();
this.x = x;
this.y = y;
// variables
this.originX = x;
this.originY = y;
this.isAlive = true;
this.visible = true;
}
die(){
if (!isAlive){
this.x = originX;
this.y = originY;
this.isAlive = true;
}
}
}
使用this.super()代替不会抛出错误,但是当添加到页面上的PIXI app.stage时,此对象仍然不会出现。
非常感谢任何建议或协助。