The ball is travelling both a vertical distance and a horizontal distance, both of which would be perceived by the stationary observer but only the vertical distance would be perceived bythe person on the train who is moving in the horizontal at an identical rate. It's a relativity example, and technically you should consider how quickly time is moving for both obervers because time is moving slightly slower for the person on the train, no?