Hi everyone, I am doing the tile map tutorial
can anyone explain me this function in deeper details please (the function is to have special animation depending on which direction my character is moving)
func animationDirection(for directionVector: CGVector)-> Direction {
let direction: Direction
//moving forward, backward, left, right
if abs(directionVector.dy) > abs(directionVector.dx) {
direction = directionVector.dy < 0 ? .forward : .backward
} else {
direction = directionVector.dx < 0 ? .left : .right
}
return direction
}
I specially don’t understand why that question mark is here.
thanks for reading and thanks in advance for your help
cheers