React-Pixi入口/ react-pixi中的遮罩

时间:2019-12-05 17:38:32

标签: reactjs pixi.js

我用于子画面的图像比所需的要大得多(910像素)。我需要动态更改容器的高度,以遮盖图像。

有人知道该怎么做吗?

<Container
      x={x}
      y={y}
      width={width}
      height={height}>
   <Sprite
        image={image}
        anchor={[0, 0]}
        x={0}
        y={0}
        width={width}
        height={910}
        rotation={0} />
 </Container>
 @inlet/react-pixi: "^1.1.9"
 pixi.js: "^5.2.0"
 react: "^16.12.0"
 react-dom: "^16.12.0"

不幸的是,这既不起作用,因为当矩形移动时纹理保持静态

 <Graphics
      draw={(g) => {
        g.clear()
        const texture = new PIXI.Texture.from(image)
        g.beginTextureFill(texture)
        g.drawRect(x, y, width, height)
        g.endFill()
      }} /> 

0 个答案:

没有答案