I have created a little game using LibGDX and it uses a SpriteBatch when it renders the game objects. Now I want to add a Touchpad to it, and the draw method of Touchpad takes a Batch as a parameter, but my game uses SpriteBatch. What can I do?
1 Answer
Because SpriteBatch
implements Batch
this means it can be used wherever a function requires a Batch
. So when you call Touchpad#draw(batch)
you can give it your SpriteBatch
instance and it will work just fine. You should probably read up on polymorphism in Java.