Refactor code in GameLayer and Player.