我在我的GameScene中有这个,它在didMove()中被调用。
for i in 1...5 {
// path to create the circle
let path = UIBezierPath(arcCenter: CGPoint(x: center.x, y: center.y), radius: CGFloat(((43 * i) + 140)), startAngle: CGFloat(GLKMathDegreesToRadians(-50)), endAngle: CGFloat(M_PI * 2), clockwise: false)
//
下面是我的圆圈象限的图片,后面跟着代码。我如何减少每一弧,例如,每边10个点/像素,以使之间的弧之间的差距?一开始,我在两边都用CGFloat(Double.pi/36)来减少它们,但左边没有产生一个直线的间隙,而是切掉了一部分,这不是我想要的。我需要每个弧线有直线边缘(水平和垂直),而不是对角线。
class GameScene: SKScene, SKPhysicsContactDelegate {
var topRightPathNode : SKShapeNode!
var bottomRightPathNode : SKShapeNode!
va
我试图沿着一个SKShapeNode移动一个UIBezierPath。下面是我到目前为止掌握的代码:
// Set up the circle track
let circleTrack = UIBezierPath(roundedRect: CGRectMake(screenWidth/2, screenHeight/2, screenWidth/3, screenWidth/3), cornerRadius: 100)
let shapeTrack = SKShapeNode(path: circleTrack.CGPath, centered: true)
sha
我想画一个半圆与底线,并重复使用它作为形状节点。我怎样才能实现这一点。这是我半圆的代码。还有一些代码是硬编码的,所以有些帮助是值得赞赏的。
func drawLine(from: CGPoint, to: CGPoint) {
// for line
let myLine = SKShapeNode()
let myPath = CGMutablePath()
myPath.addLines(between: [from, to])
myLine.path = myPath
myLine.strokeColor = SKColor.blue
my
我正在尝试从一个UIBezierPath创建一个开放的循环,并将其转化为一个SKShapeNode,稍后它将被转换为一个SKSpriteNode。
我有一个问题,我不知道如何缩小雪碧,而它的线宽没有缩小。您可以在这里看到解决方案:
最后,我修复了一些东西,并创建了一个新类来实现具有以下功能的自定义SKShapeNode:
class ShrinkableShape: SKShapeNode {
let level: Int
let bezierPath: UIBezierPath
let scale: CGFloat
let finalLineWidth: CGFloat
let from:
当用户沿着一条线跟踪时,SKShapeNode路径是由线段(它们来自底层的'tiles')构建的。实际路径是通过锁定用户以前拖过的行,并在最近的线上找到最近的接触点,然后构建如下路径来构建的:
var activatedPointPath: UIBezierPath {
let activatedPointPath = UIBezierPath()
// self.state.activatedPoints contains the end point
// of each full line segment the user has traced t