Cocos2dx Screen Swipe Effect

Hello!
Is there a easy way to implement the swpie effect to the screen in cocos2dx? I want something like this:
http://demos.jquerymobile.com/1.3.0-beta.1/docs/demos/swipe/buenosaires.html

My first though was ScrollView… but the problem is it has to detect somehow that there is a “new screen” in the scene and adjust to the edges so it looks lke in the demo above. Any nice ideas? :smile:

I did it using a scrollview, there is a tutorial somewhere on internet. Google it

Possible with scroll view… But need a little work and maybe headache…

Good luck

Use a PageView. Add an ImageView to a Layout for each page. You can then use scrollToPage for next/previous buttons as well as auto swiping.

_newsPageView = PageView::create();
// add pages here
// reset schedule every time the page view event occurs (mainly touch gestures)
auto func = [this](Ref* senderRef, PageView::EventType eventType) {
    this->unschedule(schedule_selector(MyMenu::nextNewsItem));
    this->schedule(schedule_selector(MyMenu::nextNewsItem), 4.f);
};
_newsPageView->addEventListener(func);
_newsPageView->scrollToPage(0);
this->addChild(_newsPageView);
this->schedule(schedule_selector(MyMenu::nextNewsItem), 4.f);

void MyMenu::nextNewsItem(float dt)
{
    if(_newsPageView) {
        auto nextPageIndex = _newsPageView->getCurPageIndex() + 1;
        if(nextPageIndex >= _newsPageView->getPages().size()) {
            nextPageIndex = 0;
        }
        _newsPageView->scrollToPage(nextPageIndex);
    }
}
1 Like