我正在嘗試使用 Phaser 3 框架繪制一個(gè)簡(jiǎn)單的多邊形形狀。問(wèn)題是:多邊形沒(méi)有出現(xiàn)。var config = { type:Phaser.AUTO, width:800, height:600, scene: { preload: preload, create: create, } }; var game = new Phaser.Game(config); var poly; var graphics; function preload() {} function create() { poly = new Phaser.Geom.Polygon(); poly.setTo([ new Phaser.Geom.Point(200, 100), new Phaser.Geom.Point(350, 100), new Phaser.Geom.Point(375, 200), new Phaser.Geom.Point(150, 200) ]); graphics = this.add.graphics(0, 0); graphics.fillPoints(poly.points, true); }我得到的錯(cuò)誤是:“Phaser.Polygon 不是構(gòu)造函數(shù)”,但我在有關(guān) Phaser 的教程中看到了該代碼。編輯:我按照 PhotonStorm 的建議更改了代碼,現(xiàn)在我沒(méi)有收到錯(cuò)誤,但多邊形仍然沒(méi)有出現(xiàn)。EDIT2:通過(guò)在圖形對(duì)象上調(diào)用 lineStyle 和 fillStyle 來(lái)解決。graphics = this.add.graphics(0, 0);graphics.lineStyle(5, 0xFF00FF, 1.0);graphics.fillStyle(0xFFFFFF, 1.0);graphics.fillPoints(poly.points, true);
如何使用 Phaser 3 繪制多邊形?
慕桂英546537
2021-07-02 01:06:23