Swift SpriteNode初始角度
Swift SpriteNode Initial Angle
我正在尝试将精灵的初始角度设置为 90 度。我不想调用动作,有没有办法像设置位置一样设置精灵的角度参数?
z旋转
您可以使用 SKNode
的 zRotation
属性 接受辐射
度数到辐射度
一个有用的扩展
extension Int {
var degreesToRadians: Double { return Double(self) * M_PI / 180 }
var radiansToDegrees: Double { return Double(self) * 180 / M_PI }
}
sprite.zRotation = CGFloat(90.degreesToRadians)
来自 Api 文档
The Euler rotation about the z axis (in radians).
The default value is 0.0, which indicates no rotation. A positive value indicates a counterclockwise rotation. When the coordinate system is rotated, it affects the node and its descendants. The rotation affects the node’s frame property, hit testing, rendering, and other similar characteristics.
耀西岛图像来自 here。
我正在尝试将精灵的初始角度设置为 90 度。我不想调用动作,有没有办法像设置位置一样设置精灵的角度参数?
z旋转
您可以使用 SKNode
的 zRotation
属性 接受辐射
度数到辐射度
extension Int {
var degreesToRadians: Double { return Double(self) * M_PI / 180 }
var radiansToDegrees: Double { return Double(self) * 180 / M_PI }
}
sprite.zRotation = CGFloat(90.degreesToRadians)
来自 Api 文档
The Euler rotation about the z axis (in radians).
The default value is 0.0, which indicates no rotation. A positive value indicates a counterclockwise rotation. When the coordinate system is rotated, it affects the node and its descendants. The rotation affects the node’s frame property, hit testing, rendering, and other similar characteristics.
耀西岛图像来自 here。