Commit f0cb48df authored by 13732208043's avatar 13732208043

采茶叶

parent a699f487
This diff is collapsed.
/**
* Created by renjianfeng on 2020-03-13.
*/
/*
event-pickTeaGame-init //游戏初始化
event-getchange-TeaNum //茶叶数量{初始值totalNum,总量nowNum} 改变svga动画
event-getBasket-Type //获得篮子类型 设置篮子类型 纸篮子 布篮子 竹篮子 木篮子 0 1 2 3
event-hand-grasp //手抓去点击
//event-wait-uplevel //待升级
event-add-oneScore //+1
event-pick-tea //采茶叶
event-tea-skyup //茶叶向上飞
event-setchange-TeaNum
event-setBasket-Type //设置篮子类型
*/
const customId = 'pick-tea';
......
......@@ -281,6 +281,10 @@
};
GameView.prototype.setTeaNum = function (TeaNums) {
var _this = this;
if (this.schedule) {
console.log('清理定时器,重新设置同步');
clearInterval(this.schedule);
}
var totalNum = 200;
var nowNum = 10;
this.pickTeaCount.text = nowNum + '/' + totalNum;
......@@ -288,6 +292,9 @@
var chaju = nowNum - totalNum;
console.log('chaju', chaju);
var width = this.progressbarImg.width;
var myDate = new Date();
var nowData = myDate.getTime();
console.log('nowData', nowData);
var x = -width * (1 - nowNum / totalNum);
console.log('x', x);
this.progressbarImg.x = parseFloat(x.toFixed(3));
......@@ -302,10 +309,10 @@
.to({ rotation: 360 }, speed).call(function () {
_this.teaHalfFlagImg.rotation = 0;
});
var schedule = setInterval(function () {
this.schedule = setInterval(function () {
if (nowNum == totalNum) {
console.log('达到最大长度');
clearInterval(schedule);
clearInterval(_this.schedule);
engine.Tween.pauseTweens(teaFullRotation);
_this.progressbarImg.x = 0;
_this.teaHalfFlagImg.visible = false;
......@@ -318,6 +325,8 @@
}
_this.getTeaPercentage(nowNum, totalNum);
nowNum++;
nowData = myDate.getTime();
console.log('nowData', nowData);
}, speed);
};
GameView.prototype.getTeaPercentage = function (nowNum, totalNum) {
......
This diff is collapsed.
......@@ -10,7 +10,7 @@
"verses": {
"alias": "诗句",
"type": "array<string>",
"default": "今朝有酒今朝醉,今宵更有湘江月,雨过林霏清石气,秋将山翠入诗心,生怕芳丛鹰嘴芽,老郎封寄谪仙家"
"default": "今朝有酒今朝醉,今宵更有湘江月,找出霏霏满碗花,雨过林霏清石气,秋将山翠入诗心,生怕芳丛鹰嘴芽,老郎封寄谪仙家"
},
"verseLabel": {
"alias": "提示语框xys",
......
......@@ -81,6 +81,7 @@ export default class GameView extends engine.Container {
//当前速度
private speed: number
private schedule: any
// 当前场景上面的物品
private goodsItems = []
......@@ -171,8 +172,11 @@ export default class GameView extends engine.Container {
this.initView();
this.setPickTeaLevel(1)
this.setTeaNum({ totalNum: 430, nowNum: 0 })
setInterval(() => {
this.handGrasp();
//this.setTeaNum({ totalNum: 430, nowNum: 120 })
}, 5000)
......@@ -301,6 +305,10 @@ export default class GameView extends engine.Container {
/*采茶叶活动*/
//总量除以当前 小于3分之1 没有树叶 ,3分之1到3分之2一点点树叶 ,大于3分之2满树叶
setTeaNum(TeaNums) {
if (this.schedule) {
console.log('清理定时器,重新设置同步')
clearInterval(this.schedule);
}
let totalNum = 200 //TeaNums.totalNum;
let nowNum = 10//TeaNums.nowNum;
this.pickTeaCount.text = nowNum + '/' + totalNum;
......@@ -308,6 +316,17 @@ export default class GameView extends engine.Container {
let chaju = nowNum - totalNum;
console.log('chaju', chaju);
let width = this.progressbarImg.width;
let myDate = new Date();
let nowData = myDate.getTime();
console.log('nowData', nowData)
/**/
//设置数据校正
let serverData = 0;
let dataDiff = 0;
/**/
//let rate = (443 - width * (1 - nowNum / totalNum))
//已经走得
let x = -width * (1 - nowNum / totalNum)
......@@ -327,10 +346,10 @@ export default class GameView extends engine.Container {
.to({ rotation: 360 }, speed).call(() => {
this.teaHalfFlagImg.rotation = 0;
})
let schedule = setInterval(() => {
this.schedule = setInterval(() => {
if (nowNum == totalNum) {
console.log('达到最大长度');
clearInterval(schedule);
clearInterval(this.schedule);
engine.Tween.pauseTweens(teaFullRotation);
this.progressbarImg.x = 0
this.teaHalfFlagImg.visible = false;
......@@ -343,7 +362,15 @@ export default class GameView extends engine.Container {
}
this.getTeaPercentage(nowNum, totalNum);
nowNum++;
dataDiff++;
nowData = myDate.getTime();
// if ((nowData - serverData) / 1000 - dataDiff > 3) {
// clearInterval(this.schedule);
// engine.Tween.pauseTweens(teaFullRotation);
// engine.globalEvent.dispatchEvent('event-setchange-TeaNum');
// return;
// }
console.log('nowData', nowData)
//console.log('this.progressbarImg.x', this.progressbarImg.x)
}, speed)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment