Commit 77d6802b authored by 13732208043's avatar 13732208043

采茶叶

parent f0cb48df
This diff is collapsed.
...@@ -170,15 +170,21 @@ ...@@ -170,15 +170,21 @@
this.pickTeaCount = new engine.Label(); this.pickTeaCount = new engine.Label();
this.progressbarBgImg.addChild(this.pickTeaCount); this.progressbarBgImg.addChild(this.pickTeaCount);
this.addChild(this.progressbarBgImg); this.addChild(this.progressbarBgImg);
this.initView(); var myDate = new Date();
this.setPickTeaLevel(1); var nowData = myDate.getTime();
this.setTeaNum({ totalNum: 430, nowNum: 0 }); this.setTeaNum({ totalNum: 430, nowNum: 0, serverData: nowData });
this.initChildrenPos();
setInterval(function () { setInterval(function () {
_this.handGrasp(); _this.handGrasp();
}, 5000); }, 5000);
}; };
GameView.prototype.reset = function () { GameView.prototype.reset = function () {
var _this = this;
console.log('111111111reset1'); console.log('111111111reset1');
this.initView();
setTimeout(function () {
return _this.setPickTeaLevel(1);
}, 500);
}; };
GameView.prototype.start = function () { GameView.prototype.start = function () {
}; };
...@@ -193,12 +199,6 @@ ...@@ -193,12 +199,6 @@
this.start(); this.start();
}; };
GameView.prototype.initView = function () { GameView.prototype.initView = function () {
for (var i = 0; i < this.basketSvgaGroup.length; i++) {
this.basketSvgaGroup[i].visible = false;
this.basketSvgaGroup[i].x = props.basketSvgaPos[0];
this.basketSvgaGroup[i].y = props.basketSvgaPos[1];
this.basketSvgaGroup[i].addEventListener(engine.MouseEvent.CLICK, this.showVerse, this);
}
this.pickTeaBg.mouseEnabled = false; this.pickTeaBg.mouseEnabled = false;
this.teaHalfImg.visible = false; this.teaHalfImg.visible = false;
this.pickTeaSvga.visible = false; this.pickTeaSvga.visible = false;
...@@ -207,6 +207,12 @@ ...@@ -207,6 +207,12 @@
this.initChildrenPos(); this.initChildrenPos();
}; };
GameView.prototype.initChildrenPos = function () { GameView.prototype.initChildrenPos = function () {
for (var i = 0; i < this.basketSvgaGroup.length; i++) {
this.basketSvgaGroup[i].visible = false;
this.basketSvgaGroup[i].x = props.basketSvgaPos[0];
this.basketSvgaGroup[i].y = props.basketSvgaPos[1];
this.basketSvgaGroup[i].addEventListener(engine.MouseEvent.CLICK, this.showVerse, this);
}
this.verseImg.x = props.versePos[0]; this.verseImg.x = props.versePos[0];
this.verseImg.y = props.versePos[1]; this.verseImg.y = props.versePos[1];
this.addOneSvga.x = props.addOneSvgaPos[0]; this.addOneSvga.x = props.addOneSvgaPos[0];
...@@ -248,6 +254,7 @@ ...@@ -248,6 +254,7 @@
this.verseLabel.y = 15; this.verseLabel.y = 15;
this.verseLabel['textHeight'] = 14; this.verseLabel['textHeight'] = 14;
this.verseLabel.textAlign = engine.TEXT_ALIGN.CENTER; this.verseLabel.textAlign = engine.TEXT_ALIGN.CENTER;
this.verseImg.visible = false;
this.verseImg.addChild(this.verseLabel); this.verseImg.addChild(this.verseLabel);
}; };
GameView.prototype.showVerse = function () { GameView.prototype.showVerse = function () {
...@@ -285,21 +292,24 @@ ...@@ -285,21 +292,24 @@
console.log('清理定时器,重新设置同步'); console.log('清理定时器,重新设置同步');
clearInterval(this.schedule); clearInterval(this.schedule);
} }
var totalNum = 200; var totalNum = TeaNums.totalNum;
var nowNum = 10; var nowNum = TeaNums.nowNum;
this.pickTeaCount.text = nowNum + '/' + totalNum; this.pickTeaCount.text = nowNum + '/' + totalNum;
this.getTeaPercentage(nowNum, totalNum); this.getTeaPercentage(nowNum, totalNum);
var chaju = nowNum - totalNum; var surplus = nowNum - totalNum;
console.log('chaju', chaju); console.log('surplus', surplus);
var width = this.progressbarImg.width; var width = this.progressbarImg.width;
var myDate = new Date(); var myDate = new Date();
var nowData = myDate.getTime(); var nowData = myDate.getTime();
console.log('nowData', nowData); var serverData = TeaNums.serverData;
var fbdvalue = Math.abs((nowData - serverData / 1000));
console.log('fbdvalue', fbdvalue);
var dataDiff = 0;
var x = -width * (1 - nowNum / totalNum); var x = -width * (1 - nowNum / totalNum);
console.log('x', x); console.log('x', x);
this.progressbarImg.x = parseFloat(x.toFixed(3)); this.progressbarImg.x = parseFloat(x.toFixed(3));
console.log('this.progressbarImg.x', this.progressbarImg.x); console.log('this.progressbarImg.x', this.progressbarImg.x);
var step = (width - (width - Math.abs(this.progressbarImg.x))) / chaju; var step = (width - (width - Math.abs(this.progressbarImg.x))) / surplus;
console.log('进图条每秒比例原始step', step); console.log('进图条每秒比例原始step', step);
step = parseFloat(step.toFixed(3)); step = parseFloat(step.toFixed(3));
console.log('进图条每秒比例step', step); console.log('进图条每秒比例step', step);
...@@ -325,8 +335,19 @@ ...@@ -325,8 +335,19 @@
} }
_this.getTeaPercentage(nowNum, totalNum); _this.getTeaPercentage(nowNum, totalNum);
nowNum++; nowNum++;
dataDiff++;
myDate = new Date();
nowData = myDate.getTime(); nowData = myDate.getTime();
console.log('nowData', nowData); console.log('nowData');
console.log(nowData);
console.log('nowData - serverData) / 1000 - dataDiff', (nowData - serverData) / 1000 - (fbdvalue + dataDiff));
if (Math.abs((nowData - serverData) / 1000) - dataDiff > (fbdvalue + 3)) {
clearInterval(_this.schedule);
engine.Tween.pauseTweens(teaFullRotation);
engine.globalEvent.dispatchEvent('event-setchange-TeaNum');
return;
}
console.log('this.progressbarImg.x', _this.progressbarImg.x);
}, speed); }, speed);
}; };
GameView.prototype.getTeaPercentage = function (nowNum, totalNum) { GameView.prototype.getTeaPercentage = function (nowNum, totalNum) {
...@@ -387,7 +408,7 @@ ...@@ -387,7 +408,7 @@
console.log(_this.teaHalfImg); console.log(_this.teaHalfImg);
pickTeaSVGA.addChildAt(_this.teaHalfImg, 10); pickTeaSVGA.addChildAt(_this.teaHalfImg, 10);
pickTeaSVGA.gotoAndPlay(1, true); pickTeaSVGA.gotoAndPlay(1, true);
}, 500); }, 300);
}; };
GameView.prototype.handGrasp = function () { GameView.prototype.handGrasp = function () {
console.log('handGrasp'); console.log('handGrasp');
......
This diff is collapsed.
...@@ -169,10 +169,13 @@ export default class GameView extends engine.Container { ...@@ -169,10 +169,13 @@ export default class GameView extends engine.Container {
this.addChild(this.progressbarBgImg); this.addChild(this.progressbarBgImg);
this.initView(); // this.initView();
this.setPickTeaLevel(1) // this.setPickTeaLevel(1)
this.setTeaNum({ totalNum: 430, nowNum: 0 })
let myDate = new Date();
let nowData = myDate.getTime();
this.setTeaNum({ totalNum: 430, nowNum: 0, serverData: nowData })
this.initChildrenPos();
setInterval(() => { setInterval(() => {
this.handGrasp(); this.handGrasp();
...@@ -183,7 +186,11 @@ export default class GameView extends engine.Container { ...@@ -183,7 +186,11 @@ export default class GameView extends engine.Container {
} }
reset() { reset() {
console.log('111111111reset1') console.log('111111111reset1')
//this.initView() this.initView()
setTimeout(() =>
this.setPickTeaLevel(1)
, 500)
} }
start() { start() {
...@@ -201,12 +208,12 @@ export default class GameView extends engine.Container { ...@@ -201,12 +208,12 @@ export default class GameView extends engine.Container {
} }
initView() { initView() {
for (let i = 0; i < this.basketSvgaGroup.length; i++) { // for (let i = 0; i < this.basketSvgaGroup.length; i++) {
this.basketSvgaGroup[i].visible = false // this.basketSvgaGroup[i].visible = false
this.basketSvgaGroup[i].x = props.basketSvgaPos[0]; // this.basketSvgaGroup[i].x = props.basketSvgaPos[0];
this.basketSvgaGroup[i].y = props.basketSvgaPos[1];; // this.basketSvgaGroup[i].y = props.basketSvgaPos[1];;
this.basketSvgaGroup[i].addEventListener(engine.MouseEvent.CLICK, this.showVerse, this); // this.basketSvgaGroup[i].addEventListener(engine.MouseEvent.CLICK, this.showVerse, this);
} // }
this.pickTeaBg.mouseEnabled = false; this.pickTeaBg.mouseEnabled = false;
this.teaHalfImg.visible = false; this.teaHalfImg.visible = false;
//this.teaHalfImg.source = ''; //this.teaHalfImg.source = '';
...@@ -216,10 +223,14 @@ export default class GameView extends engine.Container { ...@@ -216,10 +223,14 @@ export default class GameView extends engine.Container {
this.initChildrenPos() this.initChildrenPos()
} }
initChildrenPos() { initChildrenPos() {
for (let i = 0; i < this.basketSvgaGroup.length; i++) {
this.basketSvgaGroup[i].visible = false
this.basketSvgaGroup[i].x = props.basketSvgaPos[0];
this.basketSvgaGroup[i].y = props.basketSvgaPos[1];;
this.basketSvgaGroup[i].addEventListener(engine.MouseEvent.CLICK, this.showVerse, this);
}
this.verseImg.x = props.versePos[0] this.verseImg.x = props.versePos[0]
this.verseImg.y = props.versePos[1] this.verseImg.y = props.versePos[1]
this.addOneSvga.x = props.addOneSvgaPos[0] this.addOneSvga.x = props.addOneSvgaPos[0]
this.addOneSvga.y = props.addOneSvgaPos[1]; this.addOneSvga.y = props.addOneSvgaPos[1];
this.pickTeaSvga.x = props.pickTeaSvgaPos[0]; this.pickTeaSvga.x = props.pickTeaSvgaPos[0];
...@@ -273,7 +284,7 @@ export default class GameView extends engine.Container { ...@@ -273,7 +284,7 @@ export default class GameView extends engine.Container {
this.verseLabel.y = 15; this.verseLabel.y = 15;
this.verseLabel['textHeight'] = 14; this.verseLabel['textHeight'] = 14;
this.verseLabel.textAlign = engine.TEXT_ALIGN.CENTER; this.verseLabel.textAlign = engine.TEXT_ALIGN.CENTER;
this.verseImg.visible = false;
this.verseImg.addChild(this.verseLabel); this.verseImg.addChild(this.verseLabel);
// label.x = (width - label.width) / 2; // label.x = (width - label.width) / 2;
...@@ -309,22 +320,25 @@ export default class GameView extends engine.Container { ...@@ -309,22 +320,25 @@ export default class GameView extends engine.Container {
console.log('清理定时器,重新设置同步') console.log('清理定时器,重新设置同步')
clearInterval(this.schedule); clearInterval(this.schedule);
} }
let totalNum = 200 //TeaNums.totalNum; let totalNum = TeaNums.totalNum;
let nowNum = 10//TeaNums.nowNum; let nowNum = TeaNums.nowNum;
this.pickTeaCount.text = nowNum + '/' + totalNum; this.pickTeaCount.text = nowNum + '/' + totalNum;
this.getTeaPercentage(nowNum, totalNum); this.getTeaPercentage(nowNum, totalNum);
let chaju = nowNum - totalNum; let surplus = nowNum - totalNum;
console.log('chaju', chaju); console.log('surplus', surplus);
let width = this.progressbarImg.width; let width = this.progressbarImg.width;
let myDate = new Date(); let myDate = new Date();
let nowData = myDate.getTime(); let nowData = myDate.getTime();
console.log('nowData', nowData) let serverData = TeaNums.serverData;
//前后端本身的差值
let fbdvalue = Math.abs((nowData - serverData / 1000))
console.log('fbdvalue', fbdvalue)
/**/ /**/
//设置数据校正 //设置数据校正
let serverData = 0; // let serverData = 0;
let dataDiff = 0; let dataDiff = 0;
/**/ /**/
//let rate = (443 - width * (1 - nowNum / totalNum)) //let rate = (443 - width * (1 - nowNum / totalNum))
...@@ -333,7 +347,7 @@ export default class GameView extends engine.Container { ...@@ -333,7 +347,7 @@ export default class GameView extends engine.Container {
console.log('x', x); console.log('x', x);
this.progressbarImg.x = parseFloat(x.toFixed(3)); this.progressbarImg.x = parseFloat(x.toFixed(3));
console.log('this.progressbarImg.x', this.progressbarImg.x) console.log('this.progressbarImg.x', this.progressbarImg.x)
let step = (width - (width - Math.abs(this.progressbarImg.x))) / chaju let step = (width - (width - Math.abs(this.progressbarImg.x))) / surplus
console.log('进图条每秒比例原始step', step) console.log('进图条每秒比例原始step', step)
step = parseFloat(step.toFixed(3)); step = parseFloat(step.toFixed(3));
...@@ -363,15 +377,19 @@ export default class GameView extends engine.Container { ...@@ -363,15 +377,19 @@ export default class GameView extends engine.Container {
this.getTeaPercentage(nowNum, totalNum); this.getTeaPercentage(nowNum, totalNum);
nowNum++; nowNum++;
dataDiff++; dataDiff++;
myDate = new Date();
nowData = myDate.getTime(); nowData = myDate.getTime();
// if ((nowData - serverData) / 1000 - dataDiff > 3) { console.log('nowData')
// clearInterval(this.schedule); console.log(nowData)
// engine.Tween.pauseTweens(teaFullRotation); console.log('nowData - serverData) / 1000 - dataDiff', (nowData - serverData) / 1000 - (fbdvalue + dataDiff))
// engine.globalEvent.dispatchEvent('event-setchange-TeaNum');
// return; if (Math.abs((nowData - serverData) / 1000) - dataDiff > (fbdvalue + 3)) {
// } clearInterval(this.schedule);
console.log('nowData', nowData) engine.Tween.pauseTweens(teaFullRotation);
//console.log('this.progressbarImg.x', this.progressbarImg.x) engine.globalEvent.dispatchEvent('event-setchange-TeaNum');
return;
}
console.log('this.progressbarImg.x', this.progressbarImg.x)
}, speed) }, speed)
} }
getTeaPercentage(nowNum, totalNum) { getTeaPercentage(nowNum, totalNum) {
...@@ -442,7 +460,7 @@ export default class GameView extends engine.Container { ...@@ -442,7 +460,7 @@ export default class GameView extends engine.Container {
console.log(this.teaHalfImg); console.log(this.teaHalfImg);
pickTeaSVGA.addChildAt(this.teaHalfImg, 10) pickTeaSVGA.addChildAt(this.teaHalfImg, 10)
pickTeaSVGA.gotoAndPlay(1, true); pickTeaSVGA.gotoAndPlay(1, true);
}, 500) }, 300)
} }
handGrasp() { handGrasp() {
console.log('handGrasp') console.log('handGrasp')
......
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