[英]Conversion Type Error CGPoint to CGFloat in Swift
var _deltaTime = NSTimeInterval()
var _pointsPerScndSpeed = Double()
var bgVelocity: CGPoint = CGPointMake(_pointsPerScndSpeed, 0.0)
//Cannot convert the expression's to type 'CGFloat'
var amToMove:CGPoint = CGPointMake(bgVelocity.x * _deltaTime, bgVelocity.y * _deltaTime)
//Could not find an overload for '*' that accepts the supplied Arguments
The members of CGPoint
have the the type CGFloat
, which is a Float
on the 32-bit architecture and Double
on the 64-bit architecture. CGPoint
的成员的类型为CGFloat
,它是32位体系结构上的Float
,而在64位体系结构上是Double
。 Swift does not implicitly convert types. Swift不会隐式转换类型。 You can either use
CGFloat
consistently in your code, or add explicit casts: 您可以在代码中一致地使用
CGFloat
,或添加显式强制转换:
var bgVelocity: CGPoint = CGPointMake(CGFloat(_pointsPerScndSpeed), 0.0)
var amToMove:CGPoint = CGPointMake(bgVelocity.x * CGFloat(_deltaTime), bgVelocity.y * CGFloat(_deltaTime))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.