| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 | 
							- import { _decorator, Component, Node ,Button,director, PageView} from 'cc';
 
- const { ccclass, property } = _decorator;
 
- @ccclass('SelectScene')
 
- export class SelectScene extends Component {
 
-     @property(Node)
 
-     pageView:Node = null;
 
-     currentPageIndex:number = null;
 
-     start() {
 
-         this.currentPageIndex = this.pageView.getComponent(PageView).getCurrentPageIndex();
 
-         console.log(this.currentPageIndex);
 
-         let BtnHome = this.node.getChildByPath("UIButton/BtnHome");
 
-         BtnHome.on(Button.EventType.CLICK,this.onBtnHome,this);
 
-         let BtnHelp = this.node.getChildByPath("UIButton/BtnHelp");
 
-         BtnHelp.on(Button.EventType.CLICK,this.onBtnHelp,this);
 
-         let BtnLeft = this.node.getChildByPath("UIButton/BtnLeft");
 
-         BtnLeft.on(Button.EventType.CLICK,this.onBtnLeft,this);
 
-         let BtnRight = this.node.getChildByPath("UIButton/BtnRight");
 
-         BtnRight.on(Button.EventType.CLICK,this.onBtnRight,this);
 
-     }
 
-     onBtnHome(){
 
-         //console.log("LoginScene");
 
-         director.loadScene("LoginScene")
 
-     }
 
-     onBtnHelp(){
 
-         console.log("HelpScene");
 
-         //director.loadScene("");
 
-     }
 
-     onBtnLeft(){
 
-         // if(this.currentPageIndex < 0){
 
-         //     this.currentPageIndex = 0;
 
-         // }
 
-         // else{
 
-         //     this.currentPageIndex = this.currentPageIndex - 1;
 
-         // }
 
-         this.currentPageIndex = Math.max(0, this.currentPageIndex - 1);
 
-         this.pageView.getComponent(PageView).scrollToPage(this.currentPageIndex);  
 
-         this.pageView.getComponent(PageView).scrollToPage(this.currentPageIndex);
 
-     }
 
-     onBtnRight(){
 
-         // if(this.currentPageIndex == this.pageView.getComponent(PageView).getPages().length + 1){
 
-         //     this.currentPageIndex = this.pageView.getComponent(PageView).getPages().length;
 
-         // }else{
 
-         //     this.currentPageIndex = this.currentPageIndex + 1;
 
-         // }
 
-         //总页数totalPages  最大索引totalPages - 1
 
-         const totalPages = this.pageView.getComponent(PageView).getPages().length;  
 
-         // 确保 currentPageIndex 不会超过 totalPages - 1 
 
-         if (this.currentPageIndex === totalPages - 1) {  
 
-             this.currentPageIndex = totalPages - 1; // 保持在最后一页  
 
-         } else {  
 
-             this.currentPageIndex = Math.min(this.currentPageIndex + 1, totalPages -1);  
 
-         }  
 
-             this.pageView.getComponent(PageView).scrollToPage(this.currentPageIndex);
 
-         }
 
-     update(deltaTime: number) {
 
-     }
 
- }
 
 
  |