0

So, i'm currently working on a game in LibGDX.

I've got a class, "GraphicSprite" that extends Sprite.

public class GraphicSprite extends Sprite{

public GraphicSprite(Texture texture){
 //WHERE WOULD I IMPORT THE TEXTURE TO THE SPRITE THAT'S BEING EXTENDED?
 //SHOULD BE SOMETHING LIKE THIS? "this.(classBeingExtended) = new Sprite(texture);
}

}

When creating a SPRITE, you have to input some variables.

testSprite = new Sprite(TEXTURE HERE);

But, I want to create GraphicSprites (which extend Sprite). So if I do :

testGraphicSprite = new GraphicSprite(new Texture(".."));

How would I set the texture?

Nathan Davis
  • 5,636
  • 27
  • 39
  • 1
    possible duplicate of [How do I call one constructor from another in Java?](http://stackoverflow.com/questions/285177/how-do-i-call-one-constructor-from-another-in-java) – Nathan Davis Jan 06 '15 at 01:51
  • I don't really understand what that question is asking and how it relates to this :/ – user3610776 Jan 06 '15 at 01:52
  • Sorry, I misread that question as calling a constructor on a super class, not a constructor on the same class. My mistake. Still, this seems like a question that has surely been answered here before. Maybe someone can find it and link to it. – Nathan Davis Jan 06 '15 at 02:06

1 Answers1

1

In your constructor, simply call the "super" constructor first.

super(texture);
ErstwhileIII
  • 4,829
  • 2
  • 23
  • 37