0224995 2 månader sedan
förälder
incheckning
e9ddd2638a

+ 3 - 0
assets/Scene/LoginScene.scene

@@ -1326,6 +1326,9 @@
     "bird": {
       "__id__": 30
     },
+    "carrot": {
+      "__id__": 13
+    },
     "_id": "b7WG4PmzZIK7ojdgKHmBsb"
   },
   {

+ 1 - 1
assets/Scene/SelectScene.scene

@@ -1257,7 +1257,7 @@
     },
     "_enabled": true,
     "__prefab": null,
-    "spacing": 10,
+    "spacing": 20,
     "_spriteFrame": {
       "__uuid__": "45828f25-b50d-4c52-a591-e19491a62b8c@f9941",
       "__expectedType__": "cc.SpriteFrame"

+ 11 - 0
assets/Script/LoginScene.ts

@@ -5,10 +5,21 @@ const { ccclass, property } = _decorator;
 export class NewComponent extends Component {
     @property(Node)
     bird:Node=null;
+    @property(Node)
+    carrot:Node=null;
+    
     start() {
         let btnLogin = this.node.getChildByName("Button")
         btnLogin.on(Button.EventType.CLICK,this.onBtnLogin,this)
+        this.carrot.setScale(0.5,0.5);
         this.birdAnimation();
+        this.carrotAnimation();
+    }
+
+    carrotAnimation(){
+        tween(this.carrot)
+            .to(0.5,{scale : new Vec3(1,1)})
+            .start()
     }
 
     birdAnimation(){

+ 39 - 5
assets/Script/SelectScene.ts

@@ -1,15 +1,26 @@
-import { _decorator, Component, Node ,Button,director} from 'cc';
+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);
-        TouchEvent
+
+        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(){
@@ -23,14 +34,37 @@ export class SelectScene extends Component {
     }
 
     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) {
-        
+
     }
 }
 

+ 1 - 3
assets/Script/Start.ts

@@ -1,6 +1,5 @@
-import { _decorator, Component, Node, Vec3, tween,UIOpacity, director,Button } from 'cc';
+import { _decorator, Component, Node, Vec3, tween,UIOpacity, director,Button, find } from 'cc';
 const { ccclass, property } = _decorator;
-
 @ccclass('Start')
 export class Start extends Component {
     @property(Node)
@@ -13,7 +12,6 @@ export class Start extends Component {
     loadingPic:Node = null;
     @property(Node)
     updatePic:Node = null;
-
     start() {
         //this.bar.setScale(2,1);
         this.updatePic.getComponent(UIOpacity).opacity = 0;