Commit 78474834 authored by 13732208043's avatar 13732208043

维护更新

parent 8b6285ea
This diff is collapsed.
......@@ -40,7 +40,6 @@
return _this;
}
GameView.prototype.setup = function () {
var _this = this;
if (this._hasSetup) {
return;
}
......@@ -91,9 +90,6 @@
this.progressbarBgImg.addChild(this.pickTeaCount);
this.addChild(this.progressbarBgImg);
this.initView();
setTimeout(function () {
_this.setTeaNum({ totalNum: 10, nowNum: 0, serverData: 1585290768011 });
}, 500);
};
GameView.prototype.reset = function () {
this.initView();
......@@ -190,15 +186,12 @@
if (this.schedule) {
clearInterval(this.schedule);
}
var totalNum = TeaNums.totalNum;
var nowNum = TeaNums.nowNum + 1;
var totalNum = 100;
var nowNum = 90;
this.getTeaPercentage(nowNum, totalNum);
var surplus = nowNum - totalNum;
if (surplus == 0) {
this.progressbarImg.x = this.teaFullFlagImg.width / 2;
this.teaHalfFlagImg.visible = false;
this.teaFullFlagImg.visible = !this.teaHalfFlagImg.visible;
this.addOneSvga.visible = !this.teaHalfFlagImg.visible;
this.addOneSvga.stop();
this.gotoMaxLength();
return;
}
var width = this.progressbarImg.width;
......@@ -207,38 +200,45 @@
var serverData = TeaNums.serverData;
var fbdvalue = Math.abs((nowData - serverData));
var dataDiff = 0;
var x = -width * (1 - nowNum / totalNum);
showLog('parseFloat(x.toFixed(3))', parseFloat(x.toFixed(3)));
this.progressbarImg.x = parseFloat(x.toFixed(3)) + this.teaFullFlagImg.width / 2 - Math.abs(this.teaFullFlagImg.x);
var x = -width * (1 - (nowNum / totalNum));
showLog('原先的X:', this.progressbarImg.x);
this.progressbarImg.x = parseFloat(x.toFixed(5)) + this.teaFullFlagImg.width - Math.abs(this.teaFullFlagImg.x);
showLog('减去长款的x', this.progressbarImg.x);
showLog('this.teaFullFlagImg.width', this.teaFullFlagImg.width);
if (this.progressbarImg.x > (this.teaFullFlagImg.width / 2)) {
var minus = this.teaFullFlagImg.width - Math.abs(this.teaFullFlagImg.x) - this.progressbarImg.x;
this.progressbarImg.x = this.progressbarImg.x - this.teaFullFlagImg.width / 2 + Math.abs(this.teaFullFlagImg.x);
showLog('负段x重组', this.progressbarImg.x);
}
showLog('补宽的X', this.progressbarImg.x);
showLog('this.progressbarImg.x', this.progressbarImg.x);
var step = (this.teaFullFlagImg.width / 2 - this.progressbarImg.x) / surplus;
this.addOneSvga.play(1, true);
var speed = props.pickTeaSpeed;
var teaFullRotation = engine.Tween.get(this.teaHalfFlagImg, { loop: true })
.to({ rotation: 360 }, speed).call(function () {
_this.teaHalfFlagImg.rotation = 0;
});
if (!this.teaFullRotation) {
this.teaFullRotation = engine.Tween.get(this.teaHalfFlagImg, { loop: true })
.to({ rotation: 360 }, speed).call(function () {
_this.teaHalfFlagImg.rotation = 0;
});
}
engine.Tween.resumeTweens(this.teaFullRotation);
this.schedule = setInterval(function () {
nowNum++;
_this.addOneSvga.play(1, true);
if (nowNum == totalNum) {
clearInterval(_this.schedule);
engine.Tween.removeTweens(teaFullRotation);
_this.progressbarImg.x = _this.teaFullFlagImg.width / 2;
_this.teaHalfFlagImg.visible = false;
_this.teaFullFlagImg.visible = !_this.teaHalfFlagImg.visible;
_this.addOneSvga.visible = !_this.teaHalfFlagImg.visible;
_this.addOneSvga.stop();
_this.gotoMaxLength();
engine.Tween.pauseTweens(_this.teaFullRotation);
}
_this.getTeaPercentage(nowNum, totalNum);
if (_this.progressbarImg.x < _this.teaFullFlagImg.width / 2 + step) {
if (_this.progressbarImg.x < _this.teaFullFlagImg.width / 2) {
_this.progressbarImg.x -= step;
}
nowNum++;
_this.getTeaPercentage(nowNum, totalNum);
dataDiff += speed;
myDate = new Date();
nowData = myDate.getTime();
if (Math.abs((nowData - serverData)) - dataDiff > (fbdvalue + 3000)) {
showLog(_this.schedule);
clearInterval(_this.schedule);
engine.Tween.removeTweens(teaFullRotation);
engine.Tween.pauseTweens(_this.teaFullRotation);
engine.globalEvent.dispatchEvent('event-setchange-TeaNum');
_this.addOneSvga.visible = false;
_this.addOneSvga.stop();
......@@ -247,6 +247,9 @@
}, speed);
};
GameView.prototype.getTeaPercentage = function (nowNum, totalNum) {
if (nowNum > totalNum) {
return;
}
this.pickTeaCount.text = nowNum + '/' + totalNum;
var teaPercentage = 2;
var portion = totalNum / 3;
......@@ -261,6 +264,16 @@
this.updateTeaPercentage(teaPercentage);
}
};
GameView.prototype.gotoMaxLength = function () {
if (this.schedule) {
clearInterval(this.schedule);
}
this.progressbarImg.x = this.teaFullFlagImg.width / 2;
this.teaHalfFlagImg.visible = false;
this.teaFullFlagImg.visible = !this.teaHalfFlagImg.visible;
this.addOneSvga.visible = this.teaHalfFlagImg.visible;
this.addOneSvga.stop();
};
GameView.prototype.updateTeaPercentage = function (teaPercentage) {
if (teaPercentage === void 0) { teaPercentage = 0; }
var pickTeaSVGA = this.basketSvgaGroup[1];
......@@ -321,6 +334,7 @@
};
return GameView;
}(engine.Container));
//# sourceMappingURL=GameView.js.map
var GameWrapper = (function (_super) {
tslib.__extends(GameWrapper, _super);
......
This diff is collapsed.
......@@ -149,8 +149,6 @@ export default class GameView extends engine.Container {
mask.y = 0;
mask.alpha = 1;
//mask.fillColor = 'black'
this.progressbarImg.mask = mask
showLog(this.progressbarImg.mask)
......@@ -176,10 +174,10 @@ export default class GameView extends engine.Container {
//this.setTeaNum({ totalNum: 430, nowNum: 425, serverData: 1585290768011 })
this.initView();
setTimeout(() => {
this.setTeaNum({ totalNum: 10, nowNum: 0, serverData: 1585290768011 })
//this.setTeaNum({ totalNum: 100, nowNum: 0 })
}, 500)
// setTimeout(() => {
// this.setTeaNum({ totalNum: 100, nowNum: 0, serverData: 1585290768011 })
// //this.setTeaNum({ totalNum: 100, nowNum: 0 })
// }, 500)
}
......@@ -311,17 +309,13 @@ export default class GameView extends engine.Container {
showLog('清理定时器,重新设置同步')
clearInterval(this.schedule);
}
let totalNum = TeaNums.totalNum;
let nowNum = TeaNums.nowNum + 1
let totalNum = 100//TeaNums.totalNum;
let nowNum = /*TeaNums.nowNum*/90
showLog('nowNum:', nowNum)
this.getTeaPercentage(nowNum, totalNum);
let surplus = nowNum - totalNum;
if (surplus == 0) {
showLog('达到最大长度');
this.progressbarImg.x = this.teaFullFlagImg.width / 2
this.teaHalfFlagImg.visible = false;
this.teaFullFlagImg.visible = !this.teaHalfFlagImg.visible
this.addOneSvga.visible = !this.teaHalfFlagImg.visible
this.addOneSvga.stop();
this.gotoMaxLength();
return;
}
showLog('surplus', surplus);
......@@ -339,53 +333,58 @@ export default class GameView extends engine.Container {
/**/
//let rate = (443 - width * (1 - nowNum / totalNum))
//已经走得
let x = -width * (1 - nowNum / totalNum)
showLog('x', x);
showLog('parseFloat(x.toFixed(3))', parseFloat(x.toFixed(3)))
let x = -width * (1 - (nowNum / totalNum))
this.progressbarImg.x = parseFloat(x.toFixed(3)) + this.teaFullFlagImg.width / 2 - Math.abs(this.teaFullFlagImg.x)//)//this.teaFullFlagImg.width - Math.abs(this.teaFullFlagImg.x)
showLog('this.progressbarImg.x', this.progressbarImg.x)
showLog('原先的X:', this.progressbarImg.x)
showLog('比例后的X', x);
//showLog('parseFloat(x.toFixed(3))', parseFloat(x.toFixed(5)))
let step = (this.teaFullFlagImg.width / 2 - this.progressbarImg.x) / surplus
this.progressbarImg.x = parseFloat(x.toFixed(5)) + this.teaFullFlagImg.width - Math.abs(this.teaFullFlagImg.x)
showLog('减去长款的x', this.progressbarImg.x)
showLog('this.teaFullFlagImg.width', this.teaFullFlagImg.width)
if (this.progressbarImg.x > (this.teaFullFlagImg.width / 2)) {
let minus = this.teaFullFlagImg.width - Math.abs(this.teaFullFlagImg.x) - this.progressbarImg.x
showLog('minus', minus)
this.progressbarImg.x = this.progressbarImg.x - this.teaFullFlagImg.width / 2 + Math.abs(this.teaFullFlagImg.x)
showLog('负段x重组', this.progressbarImg.x)
}
showLog('补宽的X', this.progressbarImg.x);
showLog('this.progressbarImg.x', this.progressbarImg.x)
let step = (this.teaFullFlagImg.width / 2 - this.progressbarImg.x) / surplus
showLog('step', step)
//step = parseFloat(step.toFixed(6));
//showLog('进图条每秒比例step', step)
this.addOneSvga.play(1, true);
let speed = props.pickTeaSpeed;
//this.progressbarImg.x += step;
let teaFullRotation = engine.Tween.get(this.teaHalfFlagImg, { loop: true })
.to({ rotation: 360 }, speed).call(() => {
this.teaHalfFlagImg.rotation = 0;
})
if (!this.teaFullRotation) {
this.teaFullRotation = engine.Tween.get(this.teaHalfFlagImg, { loop: true })
.to({ rotation: 360 }, speed).call(() => {
this.teaHalfFlagImg.rotation = 0;
})
}
engine.Tween.resumeTweens(this.teaFullRotation);
this.schedule = setInterval(() => {
//showLog('nowNum', nowNum, 'totalNum', totalNum)
nowNum++;
this.addOneSvga.play(1, true);
if (nowNum == totalNum) {
showLog('达到最大长度');
clearInterval(this.schedule);
engine.Tween.removeTweens(teaFullRotation);
this.progressbarImg.x = this.teaFullFlagImg.width / 2
this.teaHalfFlagImg.visible = false;
this.teaFullFlagImg.visible = !this.teaHalfFlagImg.visible
this.addOneSvga.visible = !this.teaHalfFlagImg.visible
this.addOneSvga.stop();
this.gotoMaxLength();
engine.Tween.pauseTweens(this.teaFullRotation);
}
//showLog('nowNum', nowNum, 'totalNum', totalNum)
this.getTeaPercentage(nowNum, totalNum);
if (this.progressbarImg.x < this.teaFullFlagImg.width / 2 + step) {
if (this.progressbarImg.x < this.teaFullFlagImg.width / 2) {
this.progressbarImg.x -= step;
}
nowNum++;
this.getTeaPercentage(nowNum, totalNum);
dataDiff += speed;
myDate = new Date();
nowData = myDate.getTime();
if (Math.abs((nowData - serverData)) - dataDiff > (fbdvalue + 3000)) {
showLog('校准数据前后数据偏差过大');
showLog(Math.abs((nowData - serverData)) - dataDiff - (fbdvalue + 3000))
showLog(this.schedule)
clearInterval(this.schedule);
engine.Tween.removeTweens(teaFullRotation);
engine.Tween.pauseTweens(this.teaFullRotation);
engine.globalEvent.dispatchEvent('event-setchange-TeaNum');
this.addOneSvga.visible = false;
this.addOneSvga.stop();
......@@ -394,6 +393,9 @@ export default class GameView extends engine.Container {
}, speed)
}
getTeaPercentage(nowNum, totalNum) {
if (nowNum > totalNum) {
return;
}
this.pickTeaCount.text = nowNum + '/' + totalNum;
let teaPercentage = 2;
let portion = totalNum / 3
......@@ -410,7 +412,18 @@ export default class GameView extends engine.Container {
this.updateTeaPercentage(teaPercentage);
}
}
//进度条达到最大长度
gotoMaxLength() {
showLog('达到最大长度');
if (this.schedule) {
clearInterval(this.schedule);
}
this.progressbarImg.x = this.teaFullFlagImg.width / 2
this.teaHalfFlagImg.visible = false;
this.teaFullFlagImg.visible = !this.teaHalfFlagImg.visible
this.addOneSvga.visible = this.teaHalfFlagImg.visible
this.addOneSvga.stop();
}
//需要更换茶叶数量皮肤
updateTeaPercentage(teaPercentage = 0) {
showLog('需要更换茶叶数量皮肤')
......
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