I've encountered a coding error for my flappy bird project, in Xcode 6.1.
The code is to allow rotation of the bird, and it reads:
bird.zRotation = self.acotarMinMax(-1, max: 0.3, valor: bird.physicsBody?.velocity.dy * (bird.physicsBody?.velocity.dy < 0 ? 0.003 : 0.001))
the error occurs under dy
, it reads:
value of optional type 'CGFloat?' not unwrapped; did you mean to use '!' or '?'?
How can I correct the error, or is there another way to generate rotation?
I am a total beginner of Swift, so I'm having a hard time figuring out if this is a syntax problem or something to do with the updated version.
I obtained the code from a online tutorial, and it worked in the video.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…