gpt4 book ai didi

ios - SKShapeNode(路径: path) does not draw

转载 作者:行者123 更新时间:2023-11-30 13:18:31 25 4
gpt4 key购买 nike

在这里,我尝试为网格绘制网格线,我已成功将其边界创建为 SKShapeNode,但是在运行此代码时我无法使线条可见。

func drawGridLines() {
print("drawing")
for row in 0...40 {
let path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, grid.frame.origin
.x , grid.frame.origin.y + CGFloat(row * 10))
CGPathAddLineToPoint(path, nil, grid.frame.width, grid.frame.origin.y + CGFloat(row * 10))
let shape = SKShapeNode(path: path)
shape.path = path
shape.position = CGPoint(x: CGRectGetMidX(frame), y: CGRectGetMidY(frame))
shape.fillColor = UIColor.redColor()
shape.strokeColor = UIColor.blueColor()
shape.lineWidth = 10
addChild(shape)

for col in 0...90 {
print("y")
}
}
}

最佳答案

我将你的代码复制到我的项目中并运行,我清楚地看到那些蓝色网格线。但是,我没有变量grid,因此我将其更改为self,即SKScene。所以我认为你的这个网格有一些问题,也许它超出了屏幕。添加更多有关它的代码或自己更改它,进行一些测试。

enter image description here

关于ios - SKShapeNode(路径: path) does not draw,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38003363/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com