Generating Text that looks like it's being typed in real time..

Greetings all,

I’m trying to make text that prints out on screen letter by letter… like it looks someone is typing it in real time.   Instead of having a block of text show up, I want it to slowly look like each letter is being typed.

How to achieve this?  Sorry if this already been asked or in an obvious tutorial, I’ve looked around and couldn’t find it-

Thanks!

https://www.youtube.com/watch?v=EZVh78NiUW4&feature=youtu.be&hd=1

Here are some possibilities,have fun: 

-- Straight assignment, prints all at once local sample1 = function() local someText = display.newText( "", 10, 10, native.systemFont, 10) someText.anchorX = 0 -- Direct assign, prints immediately someText.text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." end -- Use a timer to print msg at fixed rate local sample2 = function() local someText = display.newText( "", 10, 30, native.systemFont, 10) someText.anchorX = 0 someText.typeIt = function( self, msg, index, delay ) if( index \> string.len(msg) ) then return end self.text = msg:sub( 1, index ) index = index + 1 timer.performWithDelay( delay, function() self:typeIt( msg, index, delay ) end ) end someText:typeIt( "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", 1, 250 ) end -- Use enterFrame and transition to get variations on rate local sample3 = function( x, y, msg, time, myEasing ) local someText = display.newText( "", x, y, native.systemFont, 10) someText.anchorX = 0 someText.\_index = 1 local msgLen = msg:len() someText.enterFrame = function( self ) if( self.removeSelf == nil ) then Runtime:removeEventListener( "enterFrame", self ) return end self.text = msg:sub( 1, math.round(self.\_index) ) if(self.\_index == msgLen) then Runtime:removeEventListener( "enterFrame", self ) end end Runtime:addEventListener( "enterFrame", someText ) transition.to( someText, { \_index = msgLen, time = time, transition = myEasing }) end sample1() sample2() sample3( 10, 50, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", 5000, easing.linear ) sample3( 10, 70, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", 5000, easing.inOutExpo ) sample3( 10, 90, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", 5000, easing.inOutCirc )

I didn’t mean to post this topic twice…

If a forum MOD could merge the two that’d be great - And THANK YOU Roaming!  I’ll try to test it out soon

https://www.youtube.com/watch?v=EZVh78NiUW4&feature=youtu.be&hd=1

Here are some possibilities,have fun: 

-- Straight assignment, prints all at once local sample1 = function() local someText = display.newText( "", 10, 10, native.systemFont, 10) someText.anchorX = 0 -- Direct assign, prints immediately someText.text = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit." end -- Use a timer to print msg at fixed rate local sample2 = function() local someText = display.newText( "", 10, 30, native.systemFont, 10) someText.anchorX = 0 someText.typeIt = function( self, msg, index, delay ) if( index \> string.len(msg) ) then return end self.text = msg:sub( 1, index ) index = index + 1 timer.performWithDelay( delay, function() self:typeIt( msg, index, delay ) end ) end someText:typeIt( "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", 1, 250 ) end -- Use enterFrame and transition to get variations on rate local sample3 = function( x, y, msg, time, myEasing ) local someText = display.newText( "", x, y, native.systemFont, 10) someText.anchorX = 0 someText.\_index = 1 local msgLen = msg:len() someText.enterFrame = function( self ) if( self.removeSelf == nil ) then Runtime:removeEventListener( "enterFrame", self ) return end self.text = msg:sub( 1, math.round(self.\_index) ) if(self.\_index == msgLen) then Runtime:removeEventListener( "enterFrame", self ) end end Runtime:addEventListener( "enterFrame", someText ) transition.to( someText, { \_index = msgLen, time = time, transition = myEasing }) end sample1() sample2() sample3( 10, 50, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", 5000, easing.linear ) sample3( 10, 70, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", 5000, easing.inOutExpo ) sample3( 10, 90, "Lorem ipsum dolor sit amet, consectetuer adipiscing elit.", 5000, easing.inOutCirc )

I didn’t mean to post this topic twice…

If a forum MOD could merge the two that’d be great - And THANK YOU Roaming!  I’ll try to test it out soon