Greetings.
I have been working on creating a dynamic text that appears in the scene like the talking boxes of RPG games.
So far so good, but now I want to delete the text. I tried to use a vector to store each letter but I couldn't do it. This is my current code:
void GameScene::Introduction1(float dt)
{
// we create the text that we will separate each letter to animate them one by one
Label *set1 = Label::createWithTTF("Where am I?", "Marker Felt.ttf", 60);
set1->setPosition(Point(400, 350));
set1->setOpacity(0);
addChild(set1, 4);
auto WChar = (Sprite *)set1->getLetter(currentLetter);
auto jump = JumpBy::create(0.5f, Vec2::ZERO, 60, 1);
WChar->setOpacity(255);
WChar->runAction(jump);
currentLetter++;
if (currentLetter >= set1->getStringLength()) // if the last word is shown
{
for (int i = currentLetter; i > 0; i--)//I added this for to go through each letter
{
unschedule(schedule_selector(GameScene::Introduction1)); // these 2 lines outside ...
currentLetter = 0; // ... the 'for' works perfectly
// currentLetter--; // I added this for the use of the 'for'
}
return;
}
}
I added that 'for' to look for a way to store each letter in a vector and then assign them the opacity to 0. I deleted the code for that so I don't get confused.
Any suggestion about it will be awesome. Is C++ so with a help on the code logic I can easily translate it for Cocos.
Thanks everyone.