COCOS2DX ScrollView does not affect sliding, remove elasticity tips

Source: Internet
Author: User

Sometimes need to use ScrollView but do not want to have that annoying elastic effect, naturally think of setbounds (false), but after the practice will find that the function of sliding inertia also to cancel, so that is how much you slip, how much scrolling, user experience is very poor ...
Solving this method is simple:
1. Inheriting scrollviewdelegate
2. Implementing Virtual Functions

    virtual void scrollViewDidScroll(ScrollView* view);

The function is then implemented as follows

void EquipShopItemLayer::scrollViewDidScroll(ScrollView* view){ auto layout = view -> getContainer(); float currentY = layout -> getPositionY(); if (currentY > 0) { view -> setContentOffset(Vec2(0, 0)); } if (-currentY > layout -> getContentSize().height - view -> getViewSize().height) { view -> setContentOffset(Vec2(0, -layout -> getContentSize().height + view -> getViewSize().height)); }

}

欢迎访问我的博客:helkyle.tk

COCOS2DX ScrollView does not affect sliding, remove elasticity tips

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.