COCOS滾動層顯示圖片

在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;
}

這樣就可以橫屏滾動了

發佈了43 篇原創文章 · 獲贊 12 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章