ScrollView 是滚动层,RichText 是富文本
版本 cocos2d-x 3.8.1
直接上代码好了
头文件,不管用不用得到,包涵了总没错
#include "cocos2d.h"
#include "cocostudio/CocoStudio.h"
#include "ui/CocosGUI.h"
USING_NS_CC;
using namespace cocostudio::timeline;
using namespace ui;
下面是测试代码,可以放在HelloWorld 的init() 函数里
//滚动层练习
//创建滚动层
auto test = ScrollView::create();
test->setPosition(Vec2(100, 100));
//开启滚动回弹
test->setBounceEnabled(true);
addChild(test);
//背景颜色层(非必须)
auto color = LayerColor::create(Color4B::GRAY);
color->setPosition(0, 0);
color->setAnchorPoint(Vec2(0, 0));
test->addChild(color);
//滚动层分为外框(裁剪区域)和内部层(内容),内容Size要大于外框Size
test->setContentSize(Size(300, 300));
test-