Try putting the code where you set the player sprite