在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;
}
這樣就可以橫屏滾動了