rafaskb / typing-label

A libGDX Label that appears as if it was being typed in real time.
MIT License
151 stars 20 forks source link

Parent alpha not working #28

Closed fgnm closed 4 months ago

fgnm commented 2 years ago

If the typing label is placed inside a scene2d group that fades (change alpha value) the label doesn't change alpha accordingly. The alpha works only if the text is wrapped between {GRADIENT} or {RAINBOW} but simple colors don't change alpha anymore.

This is a screen of a group with several buttons and labels with 0.4 alpha value image

Labels and buttons correctly apply parent alpha, while the typing label only works on the Treasures word which is wrapped into a {GRADIENT} tag

rafaskb commented 2 years ago

Huh that's odd, on my end changing the alpha of parents properly propagates it to all glyphs, even the ones without any tokens. image

There was a big change regarding how colors are applied to glyphs in the latest update, which is only compatible with libGDX 1.11.0 (see https://github.com/rafaskb/typing-label/releases/tag/1.3.0). Can you please double check which TypingLabel and libGDX versions you're using?

fgnm commented 2 years ago

Yes, I'm sure to be on latest versions both of typing labels and libGDX.. I tried to switch to textratypist which has a 1:1 implementation of this library and the bug was fixed there.

rafaskb commented 2 years ago

Yes, I'm sure to be on latest versions both of typing labels and libGDX.. I tried to switch to textratypist which has a 1:1 implementation of this library and the bug was fixed there.

Would you be able to provide some code containing the issue? I can't seem to reproduce it on my end.

tommyettinger commented 2 years ago

Yes, I'm sure to be on latest versions both of typing labels and libGDX.. I tried to switch to textratypist which has a 1:1 implementation of this library and the bug was fixed there.

Woohoo! I'm 1:1! (I think.) If I remember this correctly, the typing-label code I initially copied into TextraTypist didn't fully handle parentAlpha from scene2d, but by sufficiently messing with the Batch color, it did get working without a ton of effort. Any fixes I had are unlikely to directly apply to typing-label, though, because of how differently the libraries store color internally...

EtK2000 commented 4 months ago

Can confirm that I am experiencing this as well. The code below is loosely based off my use case:

class MyWindow extends VisWindow {
    private final VisTable textArea = new VisTable();
    private final VisScrollPane progressConversationScrollPane = new VisScrollPane(textArea);

    public MyWindow() {
        super("");
        progressConversationScrollPane.setFadeScrollBars(false);
        add(progressConversationScrollPane).growX().expandY().left().top().pad(5);
    }

    public void addLine(String text) {
        TypingLabel currentLine = new TypingLabel("{SLOWER}" + text, VisUI.getSkin());
        currentLine.parseTokens();
        currentLine.setTypingListener(listener);
        currentLine.setWrap(true);
        textArea.add(currentLine).growX().left().padBottom(5).padTop(5).row();
    }

    public void fadeOut() {
        clearActions();
        addAction(Actions.fadeOut(VisWindow.FADE_TIME, Interpolation.fade));
    }
}
tommyettinger commented 4 months ago

java_owrFqKqy0R If the default tokens don't include FADE or other changes to color, then parent alpha isn't respected by any text without a color set. This should help track down the culprit, so I'll take a look too.

tommyettinger commented 4 months ago

That was easy! java_tnPDOtzDZB I opened a PR, #31 .