Skip to content

Commit 5809e25

Browse files
committed
removed ?. so tercer could work
1 parent ba0acde commit 5809e25

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

‎src/entity.js‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ export default class Entity {
6464
}
6565

6666
visualUpdate() {
67-
this.sprite?.setX(this.x * this.size + this.size / 2)
68-
this.sprite?.setY(this.y * this.size + this.size / 2)
67+
if (this.sprite) {
68+
this.sprite.setX(this.x * this.size + this.size / 2)
69+
this.sprite.setY(this.y * this.size + this.size / 2)
70+
}
71+
6972
return true;
7073
}
7174

‎src/movingEntity.js‎

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,21 +69,25 @@ export default class MovingEntity extends Entity {
6969
this.deathVel = [Math.random() * 5 - 2.5, Math.random() * 5 - 2.5]
7070
} else {
7171
const [vx, vy] = this.deathVel;
72-
this.sprite.scale *= 0.95
73-
this.sprite.x += vx;
74-
this.sprite.y += vy;
75-
76-
this.sprite?.setX(this.sprite.x);
77-
this.sprite?.setY(this.sprite.y);
78-
this.sprite?.setScale(this.sprite.scale);
72+
if (this.sprite) {
73+
this.sprite.scale *= 0.95
74+
this.sprite.x += vx;
75+
this.sprite.y += vy;
76+
77+
this.sprite.setX(this.sprite.x);
78+
this.sprite.setY(this.sprite.y);
79+
this.sprite.setScale(this.sprite.scale);
80+
}
7981
}
8082
} else {
8183
let currentVisX = this.sprite.x
8284
let currentVisY = this.sprite.y
8385
let targetVisX = this.x * this.size + this.size / 2
8486
let targetVisY = this.y * this.size + this.size / 2
85-
this.sprite?.setX(currentVisX + (targetVisX - currentVisX) * 0.1)
86-
this.sprite?.setY(currentVisY + (targetVisY - currentVisY) * 0.1)
87+
if (this.sprite) {
88+
this.sprite.setX(currentVisX + (targetVisX - currentVisX) * 0.1)
89+
this.sprite.setY(currentVisY + (targetVisY - currentVisY) * 0.1)
90+
}
8791
// if (this.currentVisX > 30) {
8892
// this.destroy()
8993
// }

0 commit comments

Comments
 (0)