From the code that I see, this is what I would expect to happen:
When the "Start Game" button is pressed, the screen changes to the game screen.
Moving the toggle switch will change the direction that the ball will move when the button is pressed. The ball should only move when the button is pressed.
If the ball is far enough to the right when the toggle switch is flipped, the screen will change to the end screen. The toggle switch has to be flipped to trigger this. This is because
myFunction, which is checking the position and changing the screen, is only called within the toggleSwitch events.
Probably, you want to check the position of the ball every time the ball moves, which involves calling the function in the button press event instead.
I might be off, because I'm not sure the exact behavior you want form the game, so if that's not what you're looking for, please let me know.