cocos creator 描线

this.graphics = this.node.addComponent(cc.Graphics);
        this.graphics.fillColor = cc.color(255, 0, 0, 255);
        console.log("get this.graphics1:",this.graphics);

        // this.graphics2 = this.node.addComponent(cc.Graphics);
        // this.graphics2.fillColor = cc.color(255, 0, 0, 255);
        // console.log("add this.graphics2:",this.graphics2);

        this.graphics.moveTo(0,0);
        this.path = [cc.v2(100,100),cc.v2(200,200),cc.v2(300,300)];
        for(var i = 0; i < this.path.length; i ++) {
            console.log(this.path[0].x);
            console.log(this.path[0].y);
            this.graphics.moveTo(this.path[i].x - 1, this.path[i].y + 1);
            this.graphics.lineTo(this.path[i].x - 1, this.path[i].y - 1);
            this.graphics.lineTo(this.path[i].x + 1, this.path[i].y - 1);
            this.graphics.lineTo(this.path[i].x + 1, this.path[i].y + 1);
            this.graphics.close(); // 组成一个封闭的路径
        }
        this.graphics.fill();
cocos creator 描线_第1张图片
描点.png

你可能感兴趣的:(cocos creator 描线)