Javascript BBText

I’m using Javascript for a project and I want to change a BBText object on runtime.
But chaning the text with setBBText() doesn’t have any effect on the shown text. What am I doing wrong?
If I get (getBBText()) the text again I can see that it is set properly. Do I have to update somehow? Thanks!

// Get BBText object     
 var bbText_obj = runtimeScene.getObjects("bbText")[0];

// Check if I realy got the object -> success
console.log(bbText_obj);

// Changing the text -> no effect ???
bbText_obj.setBBText("Hi");

Your code worked for me on the web version. I’m on my phone.

Tip: when posting Javascript use the preformated text option under the gear, otherwise the site changes the quotes to a type that won’t work in Gdevelop.

I copied and pasted your code , this works on the online version. I added a bbText object and only changed its name. I put your text in a Javascript event with a mouse released to test it. IDK.

// Get BBText object

var bbText_obj = runtimeScene.getObjects("bbText")[0];

// Check if I realy got the object → success

console.log(bbText_obj);

// Changing the text → no effect ???

bbText_obj.setBBText("Hi");
1 Like

Thanks for both hints and for testing.
Somehow it doesn’t work after isFristFrame() and even not after a small delay.
But it works perfectly after a key or mouse event as you said👍

After increasing the dealy up to 3 second with:

if (runtimeScene.getTimeManager().getTimeFromStart() > 3000) {
   ...
    bbText_obj.setBBText("Hi");
}

I finally found the issue.
The Behavior BBText_AutoTyping caused the issue. After deactivating the behavior it worked like expected.

2 Likes