Make message box like pokemon game

Someone can show me how to make a message box like pokemon game, I dont know how to make label show each letter like this video. Thanks!

You can do something like this:

  1. Have your text stored in a CCLabelBMFont.
  2. Schedule iterations over each character modifying their properties (you have a lot of flexibility).
  3. In that video, it looks like the iterations aren’t at a fixed interval, it seems to be longer in between words. You can keep track of where you are in the string and increase the interval for just that update.

This isn’t full code but just a short snippet of how i would do it (untested, probably has bugs):
Whoops I just realized I’m posting in the HTML5 forum, not the C++ one, but the logic’s the same.

Class interface (pretend it’s in a class called MyScene, ideally it should be it’s own class).

private:
// some stuff

  // Keep track of where you are in the string
  int currentCharacter;
  // and when to do an update on the label.
  float normalUpdateInterval;
  float pausedUpdateInterval;

  std::string myString;
  CCLabelBMFont myFont;

// more stuff

Making the label

myString = "Some string."
myLabel = CCLabelBMFont::create(myString.c_str(), "fonts/myfont.fnt");
// Start off with all characters invisible.
myLabel->setOpacity(0);

// When you're ready to show the first character
this->scheduleOnce(schedule_selector(MyScene::myUpdateFunction));

In your update function

void MyScene::myUpdateFunction()
{
  if (currentCharacter < myString.size())
  {
    CCSprite* const CURRENT_CHAR = dynamic_cast<CCSprite*>(myLabel->getChildByTag(currentCharacter));
    if (CURRENT_CHAR) {CURRENT_CHAR->setOpacity(255);}
    currentCharacter++;

    // Extra pauses for the next character when it's a space.
    const float UPDATE_INTERVAL = isspace(myString.at(currentCharacter - 1)) ? pausedUpdateInterval : normalUpdateInterval;
    this->schedule(schedule_selector(MyScene::myUpdateFunction), UPDATE_INTERVAL);
  }
  else
  {
    this->unschedule(schedule_selector(MyScene::myUpdateFunction));
  }
}

@Jgod Thanks !!

I ended up creating a simple repo on Github for it (cpp version at least) called CCTextScroller.