In cocos2dx 3.0, tableview is generated from scrollview. It is often used as a rolling list. It has several special usage. I don't know if you have used it.
Requirements:1. You cannot select tablecell when rolling. You can only select tablecell if it is not in the rolling status.
In the delegate function of tableview, you can use the istouchmoved () function to determine
[CPP] View plaincopy
- Void weaponselectlayer: tablecellunhighlight (cocos2d: Extension: tableview * Table, cocos2d: Extension: tableviewcell * cell)
- {
- If (Table-> istouchmoved ()){
- Return;
- }
- // Todo: select item.
- }
Requirement 2: tableview cannot be dragged to the edge if no option is available.
[CPP] View plaincopy
-
- Void weaponselectlayer: scrollviewdidscroll (cocos2d: Extension: scrollview * view)
-
- {
-
- Point off = view-> getcontentoffset ();
- If (Off. Y <view-> mincontaineroffset (). Y ){
-
- View-> setcontentoffset (point (Off. X, view-> mincontaineroffset (). y ));
-
- }
-
-
- If (Off. Y> View-> maxcontaineroffset (). Y ){
-
- View-> setcontentoffset (point (Off. X, view-> maxcontaineroffset (). y ));
-
- }
-
- }
This method has a bug. When the tablecell you provide cannot be filled with the entire tableview, there will be a recursive endless loop, but the entire method can still be filled with the entire tableview, if you have a better solution, please listen.
cocos2dx development and growth path 005