Roll Text

With this tutorial I'll be looking at a few ways to do some more text effects.
In particular using BB code to hack and &(heh) our way to put some words up.

For a roll in text I'll use the y offset.
To make things a bit simpler I'll use the percent feature.

I made three instance variables added to the text object. The text I want to write. An empty string to make counting a bit easier. Then the speed I want it to roll in at.






Tween works quire nicely for this as you can use the value of the behavior for each letter and have your favorite interpolation.





Be sure BBCode is enabled, and set the horizontal alignment to left.
You want the letters to roll in from the left like you would write them.
















Since we want to do a tween for each letter we'll make things easier by using a function.
Otherwise you would need to rewrite an event to do basically the same thing after the initial letter. Behavior tags are nice, but they don't do everything.














Speaking of behavior tags:
+ Text: Is Tween "roll" playing
-> Text: Set text to Text.curstring&"[offsety="&Text.Tween.Value("roll")&"%]"&mid(Text.mystring,len(Text.curstring),1)&"" 
So while the behavior is running you want to basically rewrite the text with the current text(Text.curstring) then concatenate(&), which is basically adding for text, to that current string the current letter, and roll its y in.
To do this I use the value of the tween to set the y, and I get the letter using mid() which gives you the letter of a string with the index you supply. I got the index by using len() which is the length of a string.
Its a little complicated, but like all things easy when you break things down.

+ Text: On Tween "roll" finished
----+ System: len(Text.curstring) < len(Text.mystring)
-----> Functions: Call rollfunc
When the tween is finished with that letter, and there are still more letters... do it again.

The function( we call at the beginning, and for each letter):
* On function 'rollfunc'
-> Text: Tween "roll" value from -100 to 0 in Text.tspeed seconds (Out Back, destroy: No, loop: No, ping pong: No, repeat count: 1)
-> Text: Set curstring to left(Text.mystring, len(Text.curstring)+1)
With the way BBCode is set up 0% is where the letter normally is. Then we set the instance variable curstring to the count of letters using left(returns the first count characters of text.) of mystring, The count is made using left of len(curstring) +1.
A bit contrived I know, but still neat that we can do that.

Find the source here






Comments