graphics画线的问题

    let ctx = this.moveArea.getChildByName('runline').getComponent(cc.Graphics);

    // 画横线
    
    for(var i = 80; i < this.moveArea.height; i += 80){
        ctx.moveTo(0, i);
        ctx.lineTo(this.moveArea.width, i);
    }
    ctx.stroke();
    我想按照指定的坐标,画出一条条横线,但是上述代码无法画出来,这是什么原因?

请参考下官方demo的graphics代码。
https://github.com/cocos-creator/example-cases/tree/31a998df91bf6506a145f1452f2669ee1cdaa154/assets/cases/graphics

我知道官方demo,我现在只是要画一条条的竖线出来,不需要组成什么形状,所以每次都是moveTo一个新的起点,然后使用lineTo画一条线到终点, 在for循环外边调用了stroke,这样有什么问题?

是不是画出去了,你的this.moveArea.width是多少,按照坐标系来画一下就知道大概的位置,这个画线的貌似是以中心为原点的,我这边可以画出来的

最近研究画线,总结了下,欢迎一起来讨论
https://mp.weixin.qq.com/s/UhYAmr6PT5Ds2hA-zdlAZQ

没颜色怎么可能显示
strokeColor 线条颜色
stroke();
fillColor 填充颜色
fill();

    let width = this.col * this.truePi;
    let height = this.row * this.truePi;
    this.graphicsNode = new cc.Node();
    this.graphics = this.graphicsNode.addComponent(cc.Graphics);
    this.battelNode.addChild(this.graphicsNode, 100);
    for (let i = 0; i <= this.row; i++) {
        this.graphics.moveTo(0, i * this.truePi);
        this.graphics.lineTo(width, i * this.truePi);
    }
    for (let i = 1; i < this.col; i++) {
        this.graphics.moveTo(i * this.truePi, 0);
        this.graphics.lineTo(i * this.truePi, height);
    }
    this.graphics.strokeColor = cc.hexToColor('#ff0000');
    this.graphics.stroke();

缺了点线,有谁帮我看看吗

我在微信上没问题,不知道为什么在chrom上有问题

画网格的时候,某些坐标范围的线确实会丢失,这个应该是cocos的bug

想一下,这个bug算不上是cocos的bug, 这个跟你的设备分辨率有关。 当你画的是一个像素粗的线时, 经过坐标转换后,在opengl栅格化的过程中很有可能会丢弃掉这根线,而且这个应该是有规律性的丢失, 跟某个坐标存在倍数关系的线都会丢失。