Method to set the scale of a sprite dynamically.