【问题标题】:Phaser 3 How to fill Phaser.Curves.Path with color?Phaser 3 如何用颜色填充 Phaser.Curves.Path?
【发布时间】:2021-11-17 19:39:06
【问题描述】:

嘿!谁能帮帮我,我在将自定义 Path 渲染为 RenderTexture 时遇到了一些麻烦

如何用颜色填充路径?

我已经为我的问题准备了沙盒示例:https://stackblitz.com/edit/set-bounce-phaser-3-so-ixfkeq 这是代码示例:

function create() {
  this.add.image(400, 300, 'sky');

  graphics = new Phaser.GameObjects.Graphics(this);
  graphics.lineStyle(4, 0x00ff00);
  graphics.fillStyle(0x00ff00); // how to fill it??

  rt = this.add.renderTexture(100, 100, 100, 100).setOrigin(0.5);

  var circle = this.add
    .circle(0, 0, 50, 0xff7e00)
    .setAlpha(0.8)
    .setVisible(false);

  rt.draw(circle, 50, 50);

  // This is just example, I need complex path with curves
  const path = new Phaser.Curves.Path(); // how to fill it??
  path.lineTo(50, 0);
  path.lineTo(50, 50);
  path.lineTo(0, 50);
  path.closePath();
  path.draw(graphics);
  rt.draw(graphics, 25, 25);
}

使用此代码,我可以看到实心圆圈,并且路径只有描边

我错过了什么?

【问题讨论】:

  • 这与 pixi.js 有什么关系? :)

标签: javascript phaser-framework pixi.js


【解决方案1】:

找到答案了!

graphics.fillPoints(path.getPoints())

【讨论】:

    猜你喜欢
    • 2012-12-24
    • 1970-01-01
    • 2019-12-11
    • 2012-01-24
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多