我想作一个简单的方形物体闪烁绿色、蓝色和红色的基础上不同的条件。 我理解,没有直接的方式改变颜色的图形象PixiJS. 目前,我创建了三个图形对象是相同的颜色。 通过重叠这些目的而调整的能见度,我能够完成闪烁的动画。
我想知道,如果有一个更好的方式来"变化"的色彩,而不是作弊与的可见性。
我目前代码:
let square_red = new PIXI.Graphics();
square.beginFill(red, opacity);
square.lineStyle(lineStyle);
square.drawRect(0, 0, width, height);
square.position.set(x, y);
let square_green = new PIXI.Graphics();
square.beginFill(green, opacity);
square.lineStyle(lineStyle);
square.drawRect(0, 0, width, height);
square.position.set(x, y);
let square_blue = new PIXI.Graphics();
square.beginFill(blue, opacity);
square.lineStyle(lineStyle);
square.drawRect(0, 0, width, height);
square.position.set(x, y);
square_red.visible = true;
square_green.visible = false;
square_blue.visible = false;