Ize Posted August 6, 2018 Share Posted August 6, 2018 Hey, for my project i need a scrolling text view. I've managed to get a clunky version working but it's not optimal since you have to play around with the values every time the text changes: http://playground.babylonjs.com/#DZ7134 Is there a better way (there must be, i just suck at js :D) to do this? Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Guest Posted August 6, 2018 Share Posted August 6, 2018 Hello I cannot run your PG, seems like there are non standard character in it Quote Link to comment Share on other sites More sharing options...
Ize Posted August 6, 2018 Author Share Posted August 6, 2018 4 minutes ago, Deltakosh said: Hello I cannot run your PG, seems like there are non standard character in it i noticed this as you were replying here is another try which hopefully won't break the playground: http://playground.babylonjs.com/#T2LHL3 Quote Link to comment Share on other sites More sharing options...
Guest Posted August 6, 2018 Share Posted August 6, 2018 Well this is a good work I like it Quote Link to comment Share on other sites More sharing options...
Ize Posted August 6, 2018 Author Share Posted August 6, 2018 cool but coming back to my original question... how do i improve it? if you change the gameDesc.text variable and put in shorter or longer text the timing will be off or, depending on how short the text is, it will fit in the rectangle and doesn't even need to scroll. can i calculate how big the text / texttexture? will be given the font size / width of the object and use that so it won't truncate my text if it's longer or stop the setinterval if the text fits within it's parent? Quote Link to comment Share on other sites More sharing options...
Guest Posted August 7, 2018 Share Posted August 7, 2018 So you have font size info in the textblock object. It is inside control.fontOffset.height This is the height for one line. Then after rendering, you can get the number of lines with control.lines Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.