javascript - Phaser 3 如何用颜色填充 Phaser.Curves.Path?
问题描述
嘿!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);
}
使用此代码,我可以看到实心圆圈,并且只有路径的笔划
我错过了什么 ?
解决方案
答案找到了!
graphics.fillPoints(path.getPoints())
推荐阅读
- common-lisp - 如何从 cffi:list-foreign-libraries 获取外国库的绝对路径?
- typescript - 在 TypeScript 中执行继承时出错
- android - 错误 Logcat Android Studio 应用程序不再运行
- swift - 自 SearchBar 实施以来的 Xcode 9.4.1 TableView 问题
- json - 如何将我在 JSON 中获得的信息转换为 DOUBLE,以便我可以正确使用该信息?
- html - 查找 BeautifulSoup 的课程位置
- c# - C# 进程问题
- java - 如何实现具有多个可能重复的字符串属性的枚举类?
- python - 当数组的数量由循环形成时,如何连接每个元素的这些数组?
- html - Bootstrap中两行下方的巨大空间