I have two variables, a speed and a minimum. The speed gets compared to the minimum to see if the speed should continue decreasing. For some reason, even when the speed is equal to the minimum, it continues to decrease the speed.
var wallSpeed : CGFloat!
var wallSpeedMin : CGFloat!
var wallSpeedChange : CGFloat!
override init(){
wallSpeed = 0.0035
wallSpeedMin = 0.0034
wallSpeedChange = 0.0001
}
The speed minimum is close to the speed for testing purposes.
if wallSpeed > wallSpeedMin
{
print("Wall speed has been increased")
wallSpeed = wallSpeed - wallSpeedChange
print("New speed is \(wallSpeed!)")
}else
{
print("Player moved up screen")
//Move player up instead
playerNode.position.y = playerNode.position.y + 5
print("Players Y value is \(playerNode.position.y)")
}
It never hits the else statement, even though the wall speed is equal to the wall speed minimum after the first decrease.
Do I have my if statement set up incorrectly? What is causing this behavior?
Aucun commentaire:
Enregistrer un commentaire