Label Remove

Discussion in 'How Can I...?' started by LtgGames, Jun 13, 2021.

  1. LtgGames

    LtgGames Avid Boxer

    Joined:
    May 4, 2020
    Messages:
    126
    Likes Received:
    32
    Hi,

    How do I make a text label remove after certain seconds (in UI) and be replaced with a new one? I need to show a caption of a story, but only one sentence at a time.

    Any thoughts?
     
  2. Jaro

    Jaro Avid Boxer

    Joined:
    Sep 21, 2018
    Messages:
    387
    Likes Received:
    126
    B2 or B3 ???
     
  3. LtgGames

    LtgGames Avid Boxer

    Joined:
    May 4, 2020
    Messages:
    126
    Likes Received:
    32
    oh sorry.. B3!
     
  4. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    @LtgGames Hmm, it looks like you don't need to remove the label but only to replace its content; probably you can't do that only using default nodes in BB3 but this can be easily done with a simple custom node, a possible setup could be something like:

    Timer node > Custom node > Set UI Text node

    Here's an example:
    [​IMG]

    Here's the script content:

    let counter = 0;

    function signal(name, value, sender, source){
    if (value){
    let text = '';
    counter += 1;
    switch (counter){
    case 1: text = 'Hello adventurer!'; break;
    case 2: text = 'What brings you here?'; break;
    case 3: text = 'This is a dangerous place!'; break;
    }
    this.emitSignal('Out', text);
    }
    }

    This is the simplest solution I could find; make sure to set 'Time' and 'Number of events' attributes in the timer node, for examples if you have 3 sentences you can set the number of events to 4 so after the last sentence is shown it gets removed when the timer triggers for the 4th time.
     
    Last edited: Jun 14, 2021
    LtgGames likes this.
  5. LtgGames

    LtgGames Avid Boxer

    Joined:
    May 4, 2020
    Messages:
    126
    Likes Received:
    32
    it's a brilliant suggestion @Ivan Perfetti , but since it's a caption, the sentence needs to have different seconds. I.e. "Hello adventurer" holds for 6 seconds, "What brings you here?" in 4 seconds, etc... It seems like I need to have the same longness of the sentence with the timer-solution...
     
  6. Codifie

    Codifie Avid Boxer

    Joined:
    Apr 17, 2018
    Messages:
    364
    Likes Received:
    190
    Why wouldn’t you just use the Set Visible node. Add a delay node and toggle the visibility of the line of text when you want it to appear.
     
  7. Elite Games

    Elite Games Avid Boxer

    Joined:
    Dec 18, 2019
    Messages:
    184
    Likes Received:
    84
    Another option can set text to empty like this.

    for example
    uit.setText("");
     
  8. LtgGames

    LtgGames Avid Boxer

    Joined:
    May 4, 2020
    Messages:
    126
    Likes Received:
    32
    Yeah, thought of that... but: where to connect the visible node? And it's easy to make it invisible, but the problem is to make the label first invisible before the "set visibility"-node sets it to visible...
     

    Attached Files:

  9. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181


    There you go! Just updated it so that you can set a specific time for each sentence, you can add pauses between sentences and you can show multiple lines adding a line feed (\n), you can see everything in the attached demo bbdoc (make sure you rename it to remove the .zip extension).
     

    Attached Files:

    Jaro, Sean Buildbox and LtgGames like this.
  10. LtgGames

    LtgGames Avid Boxer

    Joined:
    May 4, 2020
    Messages:
    126
    Likes Received:
    32
    @Ivan Perfetti Wow, thanks, you are one of the best out there!
     
    Ivan Perfetti likes this.
  11. Ivan Perfetti

    Ivan Perfetti Avid Boxer

    Joined:
    Sep 9, 2018
    Messages:
    203
    Likes Received:
    181
    @LtgGames You're welcome, I'm glad it helped! :)
     
    Sean Buildbox likes this.

Share This Page