即使我将所有内容都转换为花车,我也会Cannot assigned a value of type Float to a value of type Int"
继续touchVelocityX = xFloat / timeFloat
。
let lastTouchX = locationOfLastTouch.x
let lastTouchY = locationOfLastTouch.y
let currentTouchX = touchLocation.x
let currentTouchY = touchLocation.y
let xDistance = currentTouchX - lastTouchX
let yDistance = currentTouchY - lastTouchY
let xFloat = Float(xDistance)
let yFloat = Float(yDistance)
let timeSinceLastTouch = NSDate().timeIntervalSinceDate(timeOfLastTouch)
let timeFloat : Float = Float(timeSinceLastTouch)
touchVelocityX = xFloat / timeFloat
touchVelocityY = yFloat / timeSinceLastTouch
timeOfLastTouch = NSDate()
locationOfLastTouch = touchLocation