PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Text letter by letter

Hi everyone! I'm trying to script text output letter by letter, for example, 1 letter in 0.2 s, but everytime I get only some strange behavior. I'm keeping im mind Fps class, and OnNextFrame method, but maybe some one can give me some original ideas or handy clues how to script it faster and better :)
At this moment I'm trying to use loops in OnNextFrame method with no luck :(
Hi ryumaster can you explain a bit more how is the strange behavior, and paste some piece of code?.

Thanks
Hi Ryumaster,

May be you can do something like this:

Code:
DWORD counter = 0;
DWORD letter = 0;
TCHAR text[255];
TCHAR* banner = TEXT("LETTER BY LETTER");

HRESULT MainHandler::onNextFrame(Surface* pBackBuffer, Panel* mainPanel)
{
DWORD bannerLen = _tcslen(banner);

letter = counter++ / 6; //The "6" will control the speed.
if(letter<=bannerLen){
_tcsncpy(text, banner, letter);
text[letter]=0;
}

pBackBuffer->fillRect(RGB(100,100,100));
mainPanel->drawText(10,10,Font::getSystemFontWithBorder(), Font::LEFT_ALIGN,
text);
return ReturnCode::OK;
}


I tested and it worked, but you may want to improve it a little.

Best regards,
Sergio.
Hi, Sergio, Matias!
Thank a lot, it really works. So using _tcslen is a solution. I should read MSDN more carefully; sometimes it is difficult to navigate in there.