Cocos2d-x tutorial (31)-scroll bar for TableView, cocos2dtableview

Source: Internet
Author: User

Cocos2d-x tutorial (31)-scroll bar for TableView, cocos2dtableview

Welcome to Cocos2d-x chat group: 193411763

Reprinted please indicate the original source: http://blog.csdn.net/u012945598/article/details/38587659



In many games, we see similar features:






In, when we slide TableView, the scroll bar below will also slide. When TableView slides to both ends, the scroll bar will be scaled out horizontally, and the scroll bar will also rebound as TableView rebounds, the following describes how to implement the scroll bar function.


First, create a TableView in the project and implement the methods in its protocol. What we need to use is

Virtual void scrollViewDidScroll (CCScrollView * view );

This method is called when sliding TableView. We need to determine the sliding distance of TableView in this method.


Create a new SliderBar file. The content of the SliderBar. h file is as follows:


The content of the SliderBar. cpp file is as follows:


After that, SliderBar still needs to be used in combination with TableView. First, create the tableView and sliderBar objects in the HelloWorld initialization method (do not forget the implementation of the tableView Protocol and related methods, which is omitted here ).



The following code is added to the tableView rolling callback method:



In this way, you can see the above effect.


The cocos2d-x has two layers layer1 and layer2 on the helloworld layer, both of which set tableview to listen to the two layers,

You place the two layers in a different position, give them a name, and use the name to get them...

The scroll bar of tableView in QT4

You can associate the mouse scroll event (when the focus is on tableView1) with the scrollBar of tableView1 and tableView2.

Related Article

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.