| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- let webView = require("../WebView");
- cc.Class({
- extends: cc.Component,
- properties: {
- progressBar: {
- default: null,
- type: cc.Node,
- serializable: true,
- },
- score: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- result: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- beat: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- playTime: {
- default: null,
- type: cc.Label,
- serializable: true,
- },
- calorie: {
- default: null,
- type: cc.Label,
- serializable: true,
- }
- },
- //计算成功还是失败
- onEnd(data) {
- let { hit, miss, time, kCal } = data;
- // console.log(hit, miss, time, kCal);
- this.beat.string = hit;
- this.playTime.string = time;
- this.calorie.string = kCal;
- let allHit = hit + miss;
- let score = 60;
- if (allHit !== 0)
- {
- score = Math.ceil((hit / allHit) * 100);
- this.score.string = score;
- // console.log("打击率:", this.score);
- }
- else {
- this.score.string = 0;
- }
- this.progressBar.getComponent('ProgressBar').setValue(score/100);
- if (score >= 90)
- {
- this.result.string = '优秀';
- }
- else if (score >= 60 && this.score < 90)
- {
- this.result.string = '合格';
- }
- else {
- this.result.string = '不合格';
- }
- // let updateData = {
- // gameScore: hit? hit : 0,//游戏得分
- // gameTime: time,//单位秒
- // calorieBurned: kCal? kCal : 0,//消耗的卡路里
- // };
- // console.log("上传结果:",updateData);
- // if (cc.sys.OS_WINDOWS === cc.sys.os) return;
- // if(cc.sys.isMobile)
- // {
- // webView.uploadInfo(hit.toString(),time.toString(), kCal.toString());
- // }
- },
- replay()
- {
- cc.director.loadScene('Game');
- }
- });
|