I have the button:

soundBtnStyle = new ImageButton.ImageButtonStyle();
    soundBtnStyle.up = skinBac.getDrawable("on");//
    soundBtnStyle.down = skinBac.getDrawable("off"); //

    soundsButton = new ImageButton(soundBtnStyle);
    soundsButton.setSize(120, 120);

    soundsButton.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {

call the button in the constructor,I can not figure out how to add a button to the stage.

    game.batch.draw(soundsButton, 0, 0,120, 120);
enter code here

It does not work, an error enter image description here

  • \$\begingroup\$ What is the error? \$\endgroup\$ Jul 24, 2016 at 5:48
  • \$\begingroup\$ @ SurvivalMachine update question \$\endgroup\$
    – upward
    Jul 24, 2016 at 6:40

3 Answers 3


If only there was a magical place where you could look up things like this.


I wonder if that button classes draw routine could help. Hmmmmmm.


Right after you create a new ImageButton you can add it like:

soundsButton = new ImageButton(soundBtnStyle); soundsButton.setSize(120, 120); //add button here stage.addActor(soundsButton); //set position at x=0 & y=0 as soundButton.setPosition(0,0);


The draw() method only accepts Texture and TextureRegion. You're passing an ImageButton. ImageButton is an Actor and is part of Scene2d and they are usually used along with Screen, Game and Stage. You should check this tutorial to know more about Scene2D.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .