These don't have equivalent results, so there's no point in comparing their performance. The first (A) completely ignores all characteristics of the Sprite like color, position, scale, and rotation. It should never be used and is only possible because of the unfortunate design decision to have Sprite be a subclass of TextureRegion. A design mistake that I think the original creators of libGDX admit based on comments made on GitHub.
The Sprite class in my opinion should not be used at all in most cases since it conflates a TextureRegion (image asset) with a game world object (simulation data). You should define your own GameObject class that has a TextureRegion variable and variables for the characteristics that you are using (width, height, scale, etc.). Then draw it using whichever batch.draw
overload has parameters for all the characteristics you use.
To take it a step further, you can write your own Drawable abstract wrapper class that can has variants for holding either a TextureRegion or an Animation<TextureRegion>
. Then you GameObject can reference a Drawable, and you can easily swap out different types of assets for a GameObject.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…