So now i have an image, a wordwrapped text that loads 2 lines at a time on the image, after u press Enter, and unloads everything after the final line was displayed.
Its almost done, only one thing: how can i make the text appear slowly like here:
youtube.com/watch?v=FGsfYfySBUI
just an example.
I use this to display the text:
text.setText(var)
Create a task that adds one letter to the text every few milliseconds.
David
I thought of tasks…
But i still dont know how to actually do that.
import direct.directbase.DirectStart
from direct.gui.OnscreenText import OnscreenText
from pandac.PandaModules import *
class UpdatingText(object):
def __init__(self, your_text):
self.text = list(your_text)
self.text.reverse()
self.temp = ""
self.onscreendisplay = OnscreenText(
text="", pos=(0, 0), scale=0.1)
# uncomment the next 3 lines for left-aligned text
#self.onscreendisplay = OnscreenText(
# text="", pos=(-0.99, 0), scale=0.1,
# align=TextNode.ALeft)
timestep = 0.1 # seconds
taskMgr.doMethodLater(timestep, self.addLetters, "add letters")
def addLetters(self, task):
try:
self.temp += self.text.pop()
self.onscreendisplay.setText(self.temp)
return task.again
except IndexError:
return task.done
UpdatingText("The flying spaghetti monster greets you, humble human.")
run()
How about posting that in the Snippets section?
not necessary - for most people such things are obvious. but feel free to expand it and post as a snippet then