【发布时间】:2016-10-16 15:37:10
【问题描述】:
我用 UIBezierPath 创建了一个大圆圈,并使用它把它变成了 Sprite,
let path = UIBezierPath(arcCenter: CGPoint(x: 0, y: 0), radius: CGFloat(226), startAngle: 0.0, endAngle: CGFloat(M_PI * 2), clockwise: false)
// create a shape from the path and customize it
let shape = SKShapeNode(path: path.cgPath)
shape.lineWidth = 20
shape.position = center
shape.strokeColor = UIColor(red:0.98, green:0.99, blue:0.99, alpha:1.00)
let trackViewTexture = self.view!.texture(from: shape, crop: outerPath.bounds)
let trackViewSprite = SKSpriteNode(texture: trackViewTexture)
trackViewSprite.physicsBody = SKPhysicsBody(edgeChainFrom: innerPath.cgPath)
self.addChild(trackViewSprite)
它工作正常。它完美地创建了圆圈。但我需要使用
调整它的大小SKAction.resize(byWidth: -43, height: -43, duration: 0.3)
这会使它变小一点。但是,当它调整我现在设置的 20 线宽时,由于纵横填充,它非常小。所以当我觉得它看起来像这样:
但我需要它像这样缩小——保持 20 线宽:
我该怎么做?
不知道这是否会影响任何事情,但精灵会永远随着 SKAction 旋转
-- 编辑-- 现在,如何使用此方法缩放到特定大小?比如把226x226转183x183?
【问题讨论】:
标签: ios swift swift3 uibezierpath skspritenode