I've seen the new text functions for the BGE and they are wonderful, I wanted so to try to make some zelda like text, writing, letter by letter (and with different speeds, but that's another step).

I just got stuck with the delay in the for cycle for "printing" the letters into the variable.

the classic time.sleep(0.5) freezes the game, so I went back and tried with the pulse of an always sensor. Now I don`t know how to use it.

here is my poor code:

import bge

cont = bge.logic.getCurrentController()
own = cont.owner

time = cont.sensors["Timer"]

def delay_print(s):
    w = ""
    for c in s:
        if time == True:
            w += str(c)
        own.text = w

delay_print("hello world1223456789af2f2rvetbdfb")

own.size = 0.2

1 Answer 1


Instead of using an always sensor, try a delay sensor to trigger the script. Slow it down by increasing the delay value and check 'repeat'. The text object needs an integer Game Property named 'counter' to work with the script.

import bge
cont = bge.logic.getCurrentController()
own = cont.owner

message = "Don't wish it were easier, wish you were better!"
mlen = len(message) # length of the string

if own['counter'] < mlen :
    own['counter'] += 1
    own.text = message[0 : own['counter']] # slice indices

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .