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.