I try to run this code, but the compiler overhears me that Int cannot convert to CGFloat, but I never declared min, max or value as 'Int' variables and never mentioned them before.
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
bird.physicsBody.velocity = CGVectorMake(0, 0)
bird.physicsBody.applyImpulse(CGVectorMake(0, 8))
}
func clamp (min: CGFloat, max: CGFloat, value:CGFloat) -> CGFloat {
if (value > max) {
return max
} else if (value < min){
return min
}else{
return value
}
}
override func update(currentTime: CFTimeInterval) {
bird.zRotation = self.clamp(-1, max: 0.5, value: bird.physicsBody.velocity.dy * (bird.physicsBody.velocity.dy < 0 ?0.003 : 0.001 ))
}
The compiler marks "-1", the next "Int" is not converted to "CGFloat"
Please, help
source
share