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:{ // 停车计时 trainDepart:{ // 停车计时
insideOffset:{ x: 25, y: -21}, // 内站台停车计时偏移量 insideOffset:{ x: 25, y: -21}, // 内站台停车计时偏移量
outsideOffset: { x: -25, y: 21}, // 外站台停车计时偏移量 outsideOffset: { x: -25, y: -11}, // 外站台停车计时偏移量
textFill: '#00FF00', // 文字颜色 textFill: '#00FF00', // 文字颜色
textBorderColor: '#00FF00', // 文字边框颜色 textBorderColor: '#00FF00', // 文字边框颜色
fontSize: 10 // 字体大小 fontSize: 10 // 字体大小

View File

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