CGFloat和NSTimeInterval“无法将类型为Float的值赋值为Int类型的值”

时间:2015-04-15 01:48:51

标签: ios swift

即使我将所有内容都转换为花车,我也会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

0 个答案:

没有答案