Cocos2dx development path 005

Source: Internet
Author: User

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
    1. Void weaponselectlayer: tablecellunhighlight (cocos2d: Extension: tableview * Table, cocos2d: Extension: tableviewcell * cell)
    2. {
    3. If (Table-> istouchmoved ()){
    4. Return;
    5. }
    6. // Todo: select item.
    7. }

 


Requirement 2: tableview cannot be dragged to the edge if no option is available.

 

 

[CPP] View plaincopy
  1. Void weaponselectlayer: scrollviewdidscroll (cocos2d: Extension: scrollview * view)
  2. {
  3. Point off = view-> getcontentoffset ();
  4. If (Off. Y <view-> mincontaineroffset (). Y ){
  5. View-> setcontentoffset (point (Off. X, view-> mincontaineroffset (). y ));
  6. }
  7. If (Off. Y> View-> maxcontaineroffset (). Y ){
  8. View-> setcontentoffset (point (Off. X, view-> maxcontaineroffset (). y ));
  9. }
  10. }


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

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.