【发布时间】:2015-08-08 17:05:24
【问题描述】:
在我的场景中,我使用了三个基本形状节点:正方形、圆形和三角形。我想创建一个自定义 SKAction 来动画从一种形状到另一种形状的转换。
我正在尝试在 SpriteKit 中重新创建类似 this 的内容。
我正在使用 UIBezierPath 为每个形状生成 CGPath:
//Circles
UIBezierPath(ovalInRect: CGRect)
//Squares
UIBezierPath(rect: CGRect)
//Triangles
convenience init(triangleInRect:CGRect, centered:Bool) {
self.init()
var origin = CGPointZero
if centered {
origin = CGPoint(x: -triangleInRect.width / 2, y: -triangleInRect.height / 2)
}
moveToPoint(origin)
addLineToPoint(CGPoint(x: origin.x + triangleInRect.width, y: origin.y))
addLineToPoint(CGPoint(x: origin.x + triangleInRect.width / 2, y: origin.y + triangleInRect.height))
closePath()
}
【问题讨论】:
标签: swift sprite-kit uibezierpath skaction cgpath