setstring

hi, i need setstring to set my text3d dynamically to keep player 's score. But the score keeps on overlaying layer by layer. I notice this is a bug in j3d from some mailing list. Can anyone suggest alternative for me? How to erase the text3d output on the screen and replace it with new string?

tq

One way of doing this is by the following:

create a branch group (scoreBG)

Set the capabilities for this BranchGroup
BranchGroup.ALLOW_DETACH);
BranchGroup.ALLOW_CHILDREN_READ;
BranchGroup.ALLOW_CHILDREN_WRITE;
BranchGroup.ALLOW_CHILDREN_EXTEND;

add that to the scene or a hierachy up to the scene.

create another BranchGroup (call it tmpScoreBG)
add your Text3D object to the tmpScoreBG (if you want to move the Text3D object around then you can add the Text3D to a transformgroup and then add that to the tmpScoreBG)

Next time you want to update the score then you must remove everything from the scoreBG like so

scoreBG.removeChild(0); //assuming there is only 1 thing that scoreBG has

 --- OR ---

You can detach the tmpScoreBG by doing this
tmpScoreBG.detach(); //Note, you need to set the capabilities for this to work

Now create a new Text3D and a new BranchGroup, add the Text3D to the BG and then add this BG to the scoreBG.

Repeate this for every time you want to update the text. I know it sounds like a big memory waste, constantly removing and creating new BranchGroups and Text3D’s but it works.

Also, this same process works for Text2D’s. The setString method on Text2D doesn’t work right either. Another bug I guess.