Browse Source

Add unused Signal. private textStyle for labels

Tyler Hallada 6 years ago
parent
commit
ad9167528a
3 changed files with 29 additions and 4 deletions
  1. 11 0
      src/Signal.ts
  2. 9 2
      src/Station.ts
  3. 9 2
      src/Train.ts

+ 11 - 0
src/Signal.ts

@@ -0,0 +1,11 @@
1
+import * as PIXI from 'pixi.js';
2
+
3
+export default class Signal {
4
+  public location: PIXI.Point;
5
+
6
+  constructor(
7
+    location: PIXI.Point,
8
+  ) {
9
+    this.location = location;
10
+  }
11
+}

+ 9 - 2
src/Station.ts

@@ -71,6 +71,8 @@ export default class Station {
71 71
   public label: PIXI.Text;
72 72
   public color: tinycolorInstance;
73 73
 
74
+  private textStyle: object;
75
+
74 76
   constructor(
75 77
     location: PIXI.Point,
76 78
     population: number,
@@ -85,10 +87,15 @@ export default class Station {
85 87
     // for debugging
86 88
     stationCount += 1;
87 89
     this.id = stationCount;
88
-    this.label = new PIXI.Text(`${this.id}`, {
90
+    this.textStyle = {
89 91
       fill: '#FFA500',
90 92
       fontFamily: 'monospace',
91 93
       fontSize: '12px',
92
-    });
94
+    };
95
+    this.renderLabel();
96
+  }
97
+
98
+  public renderLabel() {
99
+    this.label = new PIXI.Text(`${this.id}`, this.textStyle);
93 100
   }
94 101
 }

+ 9 - 2
src/Train.ts

@@ -15,6 +15,8 @@ export default class Train {
15 15
   public color: tinycolorInstance;
16 16
   public sprite: PIXI.Sprite;
17 17
 
18
+  private textStyle: object;
19
+
18 20
   constructor(
19 21
     location: PIXI.Point,
20 22
     speed: number,
@@ -35,15 +37,20 @@ export default class Train {
35 37
     // for debugging
36 38
     trainCount += 1;
37 39
     this.id = trainCount;
38
-    this.label = new PIXI.Text(`${this.id}`, {
40
+    this.textStyle = {
39 41
       fill: '#AEAEAE',
40 42
       fontFamily: 'monospace',
41 43
       fontSize: '12px',
42
-    });
44
+    };
45
+    this.renderLabel();
43 46
   }
44 47
 
45 48
   public boardPassengers() {
46 49
     if (this.location === this.origin.location) { // about to leave a station
47 50
     }
48 51
   }
52
+
53
+  public renderLabel() {
54
+    this.label = new PIXI.Text(`${this.id}`, this.textStyle);
55
+  }
49 56
 }