Cocos2dx/ScrollView
提供: 初心者エンジニアの簡易メモ
サンプル
下半分に複数行ラベルを表示
std::string text = StringUtils::toString(origin.y) + "\nHello World\nHello World2\n2\n2\n2\n2\n2\n2\n3\n3\n3\n3\n3\n3\n3\n4\n4\n5\n5\n5\n"; auto labelResult = Label::createWithTTF(text, "fonts/Marker Felt.ttf", 10); labelResult->setPosition(Vec2(origin.x + labelResult->getContentSize().width / 2 labelResult->getContentSize().height / 2)); ScrollView* scroll = ScrollView::create(); scroll->setContentSize(Size(labelResult->getContentSize().width, visibleSize.height / 2)); scroll->setInnerContainerSize(Size(labelResult->getContentSize().width, labelResult->getContentSize().height)); scroll->setDirection(ScrollView::Direction::VERTICAL); // 縦方向だけにスクロール scroll->setPosition(Vec2(origin.x - scroll->getContentSize().width / 2 + visibleSize.width / 2, origin.y)); scroll->addChild(labelResult, 1); addChild(scroll);