| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import gameData from "../../configData/gameData";
- const {ccclass, property} = cc._decorator;
- @ccclass
- export default class buildload extends cc.Component {
- private loadCount = 0;
- onLoad () {
- if (Math.random() < 0.5) {
- this.node.getChildByName('b1').opacity = 0;
- this.node.getChildByName('b2').opacity = 255;
- }
- else {
- this.node.getChildByName('b1').opacity = 255;
- this.node.getChildByName('b2').opacity = 0;
- }
- this.loadCount = 0;
- this.showBulidAct();
- }
- private showBulidAct() {
- if (this.loadCount == 10000) {
- return;
- }
- let times = (Number(gameData.instance().game_Const[1][2]) - 0.3) / 0.05;
- this.loadCount += 200 / times;
- let myprogress = this.node.getChildByName('hp_3').getComponent(cc.ProgressBar);
- myprogress.progress = this.loadCount / 200;
- if (this.loadCount >= 200) {
- myprogress.node.opacity = 0;
- this.node.getChildByName('hp_bg').opacity = 0;
- this.node.getChildByName('b1').opacity = 0;
- this.node.getChildByName('b2').opacity = 0;
- this.node.getChildByName('act').opacity = 255;
- this.node.getChildByName('act').getComponent(cc.Animation).play();
- this.scheduleOnce(() => {
- this.node.destroy();
- }, 0.4);
- return;
- }
- this.scheduleOnce(() => {
- this.showBulidAct();
- }, 0.05);
- }
- public stopDelate()
- {
- this.loadCount = 10000;
- this.unscheduleAllCallbacks();
- this.node.destroy();
- }
- }
|