Side scrolling text function

Hi everybody, I just made a function to side scroll text action movie style (take a look at the bottom of the post for a preview).
Put this code in global editor
In the draw event of your text actor put
Of course change the text to suit your needs, 3 changes the scrolling speed (1 being the fastest).
You have to end a sentence with | or it will get buggy!
| represents the blinking cursor, and tells the function when to stop copying text.
To change to a new row use \n as usual.
You can add sound easily.
The code works fine but I think that it has a few bugs(ex. try leaving | out), so if anyone corrects them or optimizes the code please post it here.
I hope you find a good use for it.
Please post your opinion!
Put this code in global editor
- Code: Select all
int time, blink, i;
char temp[255];
void type(char myText[255],int speed)
{
if ( strcmp(&myText[i],"|")!=0 )
{
if (time==speed)
{
if (i<254&&i!=0)
{
strcpy(text,temp);
strncat(text,&myText[i],1);
strcpy(temp,text);
strcat(text,"_");
}
else
{
strncpy(text,&myText[i],1);
strcpy(temp,text);
}
time=0;
i++;
}
time++;
}
else
{
if (time==speed*2)
{
if (blink==0)
{
strcpy(text,temp);
strcpy(temp,text);
blink=1;
}
else if (blink==1)
{
strcat(text,"_");
blink=2;
}
else
{
strcpy(text, temp);
blink=1;
}
time=0;
}
time++;
}
}
In the draw event of your text actor put
- Code: Select all
type("20:00\nThe North Valley\nOperation commencing|",3);
Of course change the text to suit your needs, 3 changes the scrolling speed (1 being the fastest).
You have to end a sentence with | or it will get buggy!
| represents the blinking cursor, and tells the function when to stop copying text.
To change to a new row use \n as usual.
You can add sound easily.
The code works fine but I think that it has a few bugs(ex. try leaving | out), so if anyone corrects them or optimizes the code please post it here.
I hope you find a good use for it.
Please post your opinion!