This commit is contained in:
fan 2020-07-24 15:29:01 +08:00
commit 8a660e75f0
3 changed files with 33 additions and 56 deletions

View File

@ -250,7 +250,7 @@ class SkinCode extends defaultStyle {
},
trainDepart:{ // 停车计时
insideOffset:{ x: 25, y: -21}, // 内站台停车计时偏移量
outsideOffset: { x: -25, y: 21}, // 外站台停车计时偏移量
outsideOffset: { x: -25, y: -11}, // 外站台停车计时偏移量
textFill: '#00FF00', // 文字颜色
textBorderColor: '#00FF00', // 文字边框颜色
fontSize: 10 // 字体大小

View File

@ -5,16 +5,12 @@ class ETrainDepart extends Group {
constructor(model) {
super();
this.model = model;
this.isNew = false;
this.timeStart = 30;
this.time = null;
this.create();
}
create(text) {
if (!this.isNew) {
create() {
const model = this.model;
const style = this.model.style;
this.isNew = true;
this.trainDepart = new Text({
zlevel: model.zlevel,
z: model.z,
@ -22,7 +18,7 @@ class ETrainDepart extends Group {
style: {
x: model.x,
y: model.y,
text: text,
text: '000',
textAlign: style.textStyle.textAlign,
fontSize: style.StationStand.trainDepart.fontSize,
fontFamily: style.fontFamily,
@ -35,7 +31,6 @@ class ETrainDepart extends Group {
});
this.add(this.trainDepart);
}
}
setColor(color) {
this.create();
@ -44,35 +39,17 @@ class ETrainDepart extends Group {
hideMode() {
this.trainDepart && this.trainDepart.hide();
// if (this.time) {
// clearInterval(this.time);
// this.timeStart = 30;
// }
}
showMode() {
// this.timeStart = 30;
this.create(`0${this.timeStart}`);
showMode(remainTime) {
if (remainTime < 10) {
remainTime = '00' + remainTime;
} else {
remainTime = '0' + remainTime;
}
this.trainDepart.setStyle('text', remainTime);
this.trainDepart.show();
setTimeout(() => {
this.animition();
}, 1000);
}
animition() {
this.time && clearInterval(this.time);
this.time = setInterval(() => {
this.timeStart--;
if (this.timeStart >= 0) {
if (this.timeStart < 10) {
this.trainDepart.setStyle('text', `00${this.timeStart}`);
} else {
this.trainDepart.setStyle('text', `0${this.timeStart}`);
}
} else {
clearInterval(this.time);
this.timeStart = 30;
}
}, 1000);
}
}

View File

@ -398,7 +398,7 @@ class StationStand extends Group {
this.safeStand && this.safeStand.setColor(this.style.StationStand.stand.stopColor);
} else {
this.trainStop && this.trainStop.showMode();
this.trainDepart && this.trainDepart.showMode();
this.trainDepart && this.trainDepart.showMode(this.model.remainTime);
}
}