Actor Libgdx scene2d appears and fades out

So I have a table sceneu2.ui:

+--------------------------------------+ |+---------+ +------------+ +---------+| || Table 1 | | ScrollPane | | Table 2 || |+---------+ +------------+ +---------+| +--------------------------------------+ | My Actor | +--------------------------------------+ 

Inside scrollpane is another table . The case is also a table . Table 1 , Table 2 and table inside scrollpane have the same number of rows.

My Actor is a simple image button actor that also supports mouse hovering.

The problem is that My Actor does not appear first (but the border exists - it is checked by the debug line of the table), but when I scroll through something in the scrollpane (with the mouse), it appears for 2 seconds and then it starts to disappear. (expected result should appear all the time)

What am I doing wrong?


My Actor Class:

 public class GameButton extends Actor { public static abstract class Listener { public abstract void onClick(); } final Texture[] current; final Listener listener; boolean disabled; int state = 0; public GameButton(Texture[] current, final Listener listener) { this.current = current; setWidth(current[0].getWidth()); setHeight(current[0].getHeight()); this.listener = listener; disabled = false; this.addListener(new InputListener() { boolean just_up = false; @Override public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { state = 2; return true; } @Override public void touchUp (InputEvent event, float x, float y, int pointer, int button) { state = 0; if (hit(x, y, false) != null) { just_up = true; state = 1; if (listener != null && !disabled) listener.onClick(); } } @Override public void enter (InputEvent event, float x, float y, int pointer, Actor fromActor) { if (state == 0) state = 1; } @Override public void exit (InputEvent event, float x, float y, int pointer, Actor toActor) { if (!just_up) state = 0; just_up = false; } }); } public void setDisabled(boolean disabled) { this.disabled = disabled; } @Override public void draw(SpriteBatch batch, float _) { super.draw(batch, _); batch.draw(current[disabled ? 0 : state], getX(), getY(), getWidth(), getHeight()); } } 

The code used to add to the table:

  btnBack = new GameButton(Assets.btnBack, 0, 0, new GameButton.Listener() { @Override public void onClick() { /* removed */ } }); add(btnBack).colspan(3).right().bottom().height(128); 
+4
source share
3 answers

I understand that this question is 2 years old, but I also had this problem, so I decided to publish my solution. For me, it was just a case where the scrollbar disappears to false using

 ScrollPane scroll = new ScrollPane(); scroll.setFadeScrollBars(false); 
+5
source

add setColor (1,1,1,1) to the drawing method in the actor

 @Override public void draw(SpriteBatch batch, float _) { batch.setColor(1,1,1,1); super.draw(batch, _); batch.draw(current[disabled ? 0 : state], getX(), getY(), getWidth(), getHeight()); } 
+3
source

By default, an "empty" skin / behavior for ScrollPane performs some attenuation. I don’t understand why, but this can lead to other things on the screen also disappearing. I had the same problem with background images. I suspect that if you define your own skin for ScrollPane, you will see that your button has appeared.

0
source

Source: https://habr.com/ru/post/1495449/