在init里面写上
m_RulePlaySprite = cocos2d::extension::ScrollView::
create(Size(890, 440));//显示的宽度和高度
m_RulePlaySprite->setAnchorPoint(Point(0, 0));
m_RulePlaySprite->setPosition(190, 60);//显示区域的位置
m_RulePlaySprite->setDirection(cocos2d::
extension::ScrollView::Direction::HORIZONTAL); //VERTICAL纵向滚动 HORIZONTAL横向滚动
m_RulePlaySprite->setContainer(x_RulePlaySprite());
addChild(m_RulePlaySprite, 1);//1是优先级 越大则优先级越高
x_RulePlaySprite函数:
void Hello::x_RulePlaySprite()
{
auto sprite = Sprite::create("1.png");
return sprite;
}
这样就可以横屏滚动了