求助Graphics的问题

  • Creator 版本: 2.4.5

  • 目标平台: chrome

用两个for循环创建一个网格,竖线可以绘制出来,但是横线就绘制不出来,嵌套for循环和分开写都试过,结果都是一样,log出来的坐标也都是对的,但是横线就是出不来,请大佬们帮忙看一下,谢谢了。

const graphics = this.guideLine.addComponent(cc.Graphics);
        const rowAndCol = DataManager.Instance.rowAndCol.get(DataManager.Instance.curRowAndCol);
        const originX = -this.bgPic.width / 2;
        const originY = this.bgPic.height / 2;
        const blockWidth = this.bgPic.width / rowAndCol.col;
        const blockHeight = this.bgPic.height / rowAndCol.row;
        for (let i = 0; i < rowAndCol.row; i++) {
            graphics.moveTo(originX, originY - i * blockHeight);
            graphics.lineTo(originX + this.bgPic.width, originY - i * blockHeight);
            for (let j = 0; j < rowAndCol.col; j++) {
                graphics.moveTo(originX + j * blockWidth, originY);
                graphics.lineTo(originX + j * blockWidth, originY - this.bgPic.height);
            }
        }
        graphics.stroke();

把线的宽度设为大于1试试

试了,还是只出竖线不出横线

NewProject_24.zip (278.2 KB)
看着挺正常

很无语,现在确认是在chrome上不同的模拟设备显示不同