In this code, one of my sprites should reduce speed until it meets 0.75. However, once the code does get to 0.75, it keeps reducing for some reason. I have a timer which calls the speed_Control func every 0.2 seconds and the sprite.speed starts at 1.0.
func speed_Control() {
if boolDecrease == true {
speed_Decrease()
}
}
func speed_Decrease() {
if sprite.speed != 0.75 {
println(sprite.speed)
sprite.speed -= 0.05
} else {
boolDecrease = false
}
}
I added println(sprite.speed) to see if my sprite does actually ever return 0.75, which it does, so I don't know how it passes if sprite.speed != 0.75.
Can anybody see what is wrong with this?