118 lines
3.0 KiB
TypeScript
118 lines
3.0 KiB
TypeScript
|
|
const {ccclass, property} = cc._decorator;
|
|
|
|
@ccclass
|
|
export default class NewClass extends cc.Component {
|
|
@property(cc.Label)
|
|
count: cc.Label = null;
|
|
@property(cc.Label)
|
|
time: cc.Label = null;
|
|
@property(cc.Sprite)
|
|
finishiTime: cc.Sprite = null;
|
|
listData: any;
|
|
selfData: any;
|
|
accuracy:number;
|
|
|
|
// onLoad () {}
|
|
start () {
|
|
this.count.string = 0 + "";
|
|
this.init();
|
|
|
|
}
|
|
//初始化数据
|
|
init(){
|
|
//展示准确率
|
|
this.showAccuracy();
|
|
//展示完成时间
|
|
this.showFinishiTime();
|
|
//上传排行榜
|
|
this.setRank();
|
|
//删除本关卡
|
|
setTimeout(() => {
|
|
cc.fx.GameTool.getCustom(true);
|
|
}, 100);
|
|
}
|
|
|
|
setRank(){
|
|
let data = {
|
|
"totleTimes": cc.fx.GameConfig.GM_INFO.stepTimeList,
|
|
"accuracy": this.accuracy,
|
|
}
|
|
cc.fx.GameTool.setRank(data);
|
|
}
|
|
|
|
showFinishiTime(){
|
|
cc.tween(this.finishiTime)
|
|
.delay(1.5)
|
|
.to(0.5,{fillRange:1})
|
|
.start();
|
|
cc.tween(this.time.node)
|
|
.delay(1.7)
|
|
.to(0.3,{opacity:255})
|
|
.call(()=>{
|
|
this.conversionTime();
|
|
})
|
|
.start();
|
|
}
|
|
|
|
conversionTime(){
|
|
var minute = 0;
|
|
var second = 0;
|
|
let obj = {a:100};
|
|
let time = parseInt(cc.fx.GameConfig.GM_INFO.stepTimeList/1000 + "");
|
|
cc.tween(obj)
|
|
// .delay(0.1)
|
|
.to(1,{a:time},{
|
|
progress: (start,end,current,ratio)=>{
|
|
current = end*ratio;
|
|
second = current.toFixed(0);
|
|
if(second >= 60){
|
|
minute = parseInt(second/60+"");
|
|
second -= 60*minute;
|
|
}
|
|
this.time.string = minute + "分" + second + "秒";
|
|
}
|
|
})
|
|
.call(()=>{
|
|
this.node.getChildByName("btn").active = true;
|
|
cc.tween(this.node.getChildByName("btn"))
|
|
.to(0.3,{opacity:255})
|
|
.start();
|
|
})
|
|
.start()
|
|
}
|
|
|
|
showAccuracy(){
|
|
this.accuracy = parseInt(cc.fx.GameConfig.GM_INFO.successList.length/
|
|
cc.fx.GameConfig.GM_INFO.level*100+"");
|
|
|
|
console.log("答对的个数:",cc.fx.GameConfig.GM_INFO.successList.length);
|
|
console.log("总数:",cc.fx.GameConfig.GM_INFO.level);
|
|
console.log("准确率:",this.accuracy);
|
|
let obj = {a:100};
|
|
cc.tween(obj)
|
|
.delay(0.5)
|
|
.to(1,{a:this.accuracy},{
|
|
progress: (start,end,current,ratio)=>{
|
|
current = end*ratio;
|
|
current = current.toFixed(0);
|
|
this.count.string = current + "";
|
|
}
|
|
})
|
|
.start()
|
|
}
|
|
|
|
//打开排行榜
|
|
openRank(){
|
|
cc.director.loadScene("RankScene");
|
|
}
|
|
//重新开始玩
|
|
again(){
|
|
cc.director.loadScene("GameScene");
|
|
}
|
|
|
|
update(dt: number): void {
|
|
// this.count.string = this.accuracy + "";
|
|
}
|
|
}
|