0224995 6 months ago
parent
commit
6e8f143431

+ 127 - 15
assets/Scene/MainScene.scene

@@ -23,7 +23,7 @@
     "_active": true,
     "_components": [],
     "_prefab": {
-      "__id__": 74
+      "__id__": 77
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -54,7 +54,7 @@
     },
     "autoReleaseAssets": false,
     "_globals": {
-      "__id__": 75
+      "__id__": 78
     },
     "_id": "c72c6c69-975b-4f6b-a208-9d0dcde54d79"
   },
@@ -84,21 +84,24 @@
       },
       {
         "__id__": 66
+      },
+      {
+        "__id__": 70
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 70
+        "__id__": 73
       },
       {
-        "__id__": 71
+        "__id__": 74
       },
       {
-        "__id__": 72
+        "__id__": 75
       },
       {
-        "__id__": 73
+        "__id__": 76
       }
     ],
     "_prefab": null,
@@ -2648,6 +2651,115 @@
     },
     "_id": "59MIbv2EBHuZuN6QLS2qub"
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "boss_05_normal",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 2
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 71
+      },
+      {
+        "__id__": 72
+      }
+    ],
+    "_prefab": null,
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": -418,
+      "y": 40,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": "0eGXDuQ1FMGbtfD5EwiBwj"
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 70
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 77.572,
+      "height": 55.474999999999994
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": "d0ewW8i5RDyqahTN6tR2GC"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 70
+    },
+    "_enabled": true,
+    "__prefab": null,
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "140690a2-d415-455c-a876-24e7c1dc88ed@f8dbc",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 0,
+    "_fillType": 0,
+    "_sizeMode": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
+    "_id": "7dKGiCgsRFd5QjpcgA59wV"
+  },
   {
     "__type__": "cc.UITransform",
     "_name": "",
@@ -2727,7 +2839,7 @@
     "_enabled": true,
     "__prefab": null,
     "countDown": {
-      "__uuid__": "7e8bd4ec-9799-4c1a-a581-99ea0db4895b",
+      "__uuid__": "059f4316-e815-4e7f-af18-fc104ce3f1f5",
       "__expectedType__": "cc.Prefab"
     },
     "_id": "9c7Qp2u0JNr6hgauO2KSFg"
@@ -2743,28 +2855,28 @@
   {
     "__type__": "cc.SceneGlobals",
     "ambient": {
-      "__id__": 76
+      "__id__": 79
     },
     "shadows": {
-      "__id__": 77
+      "__id__": 80
     },
     "_skybox": {
-      "__id__": 78
+      "__id__": 81
     },
     "fog": {
-      "__id__": 79
+      "__id__": 82
     },
     "octree": {
-      "__id__": 80
+      "__id__": 83
     },
     "skin": {
-      "__id__": 81
+      "__id__": 84
     },
     "lightProbeInfo": {
-      "__id__": 82
+      "__id__": 85
     },
     "postSettings": {
-      "__id__": 83
+      "__id__": 86
     },
     "bakedWithStationaryMainLight": false,
     "bakedWithHighpLightmap": false

+ 3 - 1
assets/Script/CountDown.ts

@@ -11,6 +11,8 @@ export class CountDown extends Component {
     imageDisplay:Sprite = null;
     countdownDuration:number = 4;
     displayTime:number = 1;
+
+    isOver:boolean = false;
     start() {
         this.imageDisplay = this.node.getChildByPath("countdown_11/countdown_01").getComponent(Sprite);
         this.showCountDown();
@@ -19,7 +21,7 @@ export class CountDown extends Component {
         tween(this.countdown_12)
             .to(this.countdownDuration,{eulerAngles :  new Vec3 (0,0,360*4)})
             //.call(()=>{this.imageDisplay.enabled = false})
-            .call(()=>{this.node.destroy()})
+            .call(()=>{this.isOver = true ; this.node.destroy()})
             .start();
         for(let i = 0;i < 4;i++){
             this.scheduleOnce(()=>{

+ 17 - 0
assets/Script/GameData.ts

@@ -0,0 +1,17 @@
+// import { _decorator, Component, Node } from 'cc';
+// const { ccclass, property } = _decorator;
+
+// @ccclass('GameData')
+export class GameData{
+    static speed:number = 100;
+
+    // start() {
+
+    // }
+
+    // update(deltaTime: number) {
+        
+    // }
+}
+
+

+ 9 - 0
assets/Script/GameData.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.23",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "1ed6c6f8-f5c6-419f-9057-0b9656d08556",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 28 - 9
assets/Script/MainScene.ts

@@ -1,23 +1,42 @@
-import { _decorator, Component, director, instantiate, Node, Prefab, resources } from 'cc';
-import { CountDown } from './CountDown';
+import { _decorator, Component, director, instantiate, Node, Prefab,  UITransform, Vec3 } from 'cc';
+import { GameData } from './GameData';
 const { ccclass, property } = _decorator;
 
 @ccclass('MainScene')
 export class MainScene extends Component {
     @property(Prefab)
     countDown:Prefab;
+    
+    speed:number = 0;
+    boss:Node = null;
+    countDownTS:any = null;
+
+    protected onLoad(){
+        //let gameData = instantiate(GameData);
+        this.speed = GameData.speed;
+    }
+
     start() {
-        
         let countDown = instantiate(this.countDown);
-        console.log(countDown.active)
-        
-        director.getScene().addChild(countDown);
-        countDown.setPosition(100,110);
-    }
+        this.node.addChild(countDown);
+        //获取倒计时预制体脚本
+        this.countDownTS = countDown.getComponent("CountDown");
 
+        this.boss = this.node.getChildByName("boss_05_normal");
+    }
 
     update(deltaTime: number) {
-        
+        //倒计时结束,游戏开始
+        if(this.countDownTS.isOver){
+            let x =this.boss.getPosition().x;
+            x += this.speed * deltaTime;
+       
+            if(x >= (this.node.getComponent(UITransform).contentSize.width)/2){
+                this.speed = 0;
+            }else{
+                this.boss.setPosition(new Vec3(x,this.boss.getPosition().y));
+            }
+        }
     }
 }
 

+ 21 - 2
assets/Script/Menu.ts

@@ -1,4 +1,6 @@
-import { _decorator, Button, Component,director,find,game,Mask,Node,Prefab,Sprite, SpriteFrame } from 'cc';
+import { _decorator, Button, Component,director,game,Node,Sprite, SpriteFrame } from 'cc';
+import { GameData } from './GameData';
+import { MainScene } from './MainScene';
 const { ccclass, property } = _decorator;
 
 @ccclass('Menu')
@@ -33,10 +35,14 @@ export class Menu extends Component {
     isPause:boolean = false;//是否暂停
     currentPauseState:boolean = null;//当前状态
 
+    currentSpeed:number = null;//当前速度
+
     start(){
         this.dialog = this.node.getChildByName("Dialog");
         this.dialog.active = false;
 
+        this.currentSpeed = GameData.speed;//将初始速度赋值给当前速度
+
         // let btnQuit = this.dialog.getChildByName("BtnQuit");
         // btnQuit.on(Button.EventType.CLICK,this.onBtnQuitDialog,this)
 
@@ -73,11 +79,18 @@ export class Menu extends Component {
     //加速
     onBtnSpeed(){
         let btnSpeedComponent = this.btnSpeed.getComponent(Sprite);
+        //获取父节点MainScene的脚本组件
+        let mainSceneTS = this.node.parent.getComponent(MainScene);
+
         this.isAccelerate = !this.isAccelerate;//加速
         this.currentState = this.isAccelerate;//当前状态为加速
         if(!this.isAccelerate){
+            //一倍速
+            mainSceneTS.speed = this.currentSpeed;
             btnSpeedComponent.spriteFrame  = this.imgSpeed_1;
         }else{
+            //二倍速
+            mainSceneTS.speed = mainSceneTS.speed * 2
             btnSpeedComponent.spriteFrame  = this.imgSpeed_2;
         }
     }
@@ -91,7 +104,14 @@ export class Menu extends Component {
         if(!this.isPause){
             menuCenterComponent.spriteFrame = this.imgMenuCenter_1;
             btnPauseComponent.spriteFrame  = this.imgPause_1;
+            //恢复暂停
+            if(director.isPaused){
+                director.resume();
+                return;
+            }
         }else{
+            //暂停
+            director.pause();
             menuCenterComponent.spriteFrame = this.imgMenuCenter_2;
             btnPauseComponent.spriteFrame  = this.imgPause_2;
         }
@@ -124,7 +144,6 @@ export class Menu extends Component {
         console.log("Restart");
     }
 
-
     update(deltaTime: number) {
         
     }