Commit 78474834 authored by 13732208043's avatar 13732208043

维护更新

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