cocos2d-x 3.0 で使用できるラベルの大きさに制限はありますか? 「タイプライター」効果を作成しようとしていますが、文字列が 45 文字以下の場合に機能するようです。これ以上だといつもの で失敗EXC_BAD_ACCESS
。以下は、このタイプライター効果を実行するために使用しようとしているコードです。
const char *labelText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis elementum turpis nec erat auctor tempor. Aenean at lorem quis erat vehicula volutpat pretium in arcu. Nulla facilisi. Vestibulum ac nibh eros. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.";
// Set up the label.
auto textLabel = Label::createWithBMFont("CopperplateBold16.fnt",
labelText,
TextHAlignment::LEFT,
textBacking->getContentSize().width - 200);
textLabel->setPosition(Vec2(origin.x + visibleSize.width * 0.5,
origin.y + visibleSize.height * 0.5));
this->addChild(textLabel, 2);
const int numChars = textLabel->getStringLength();
for (int i = 0; i < numChars; i++) {
CCLOG("Char: %d", i);
Sprite* charSprite = textLabel->getLetter(i);
charSprite->setScale(0);
float delaySec = (10.0/(numChars - 1)) * i;
DelayTime *delay = DelayTime::create(delaySec);
ScaleTo *appear = ScaleTo::create(0, 1);
Sequence *delayAndShow = Sequence::create(delay, appear, NULL);
charSprite->runAction(delayAndShow);
}
これはcharSprite->setScale(0)
45 文字以降で終了します。何か案は?