mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-26 03:38:58 +00:00
named index 0
This commit is contained in:
parent
91ad84e338
commit
e626d493d2
@ -60,14 +60,15 @@ export class Background extends Component {
|
||||
}
|
||||
} else if (this.playerGridPosX < playerGridPosX) {
|
||||
// move the first column to the right
|
||||
const columnIndex = 0;
|
||||
for (let i = 0; i < this.rows; i++) {
|
||||
const instancedNode = this.instancedBackgrounds[i][0];
|
||||
const instancedNode = this.instancedBackgrounds[i][columnIndex];
|
||||
const newPosition: Vec3 = instancedNode.worldPosition;
|
||||
newPosition.x += this.columns * this.nodeSize;
|
||||
|
||||
instancedNode.setWorldPosition(newPosition);
|
||||
|
||||
this.instancedBackgrounds[i].splice(0, 1);
|
||||
this.instancedBackgrounds[i].splice(columnIndex, 1);
|
||||
this.instancedBackgrounds[i].push(instancedNode);
|
||||
}
|
||||
}
|
||||
@ -95,9 +96,10 @@ export class Background extends Component {
|
||||
this.instancedBackgrounds.unshift(nodesInRow);
|
||||
} else if (this.playerGridPosY < playerGridPosY) {
|
||||
// move the first row up
|
||||
const rowIndex = 0;
|
||||
const nodesInRow: Node[] = [];
|
||||
for (let i = 0; i < this.columns; i++) {
|
||||
const instancedNode = this.instancedBackgrounds[0][i];
|
||||
const instancedNode = this.instancedBackgrounds[rowIndex][i];
|
||||
const newPosition: Vec3 = instancedNode.worldPosition;
|
||||
newPosition.y += this.rows * this.nodeSize;
|
||||
|
||||
@ -105,7 +107,7 @@ export class Background extends Component {
|
||||
nodesInRow.push(instancedNode);
|
||||
}
|
||||
|
||||
this.instancedBackgrounds.splice(0, 1);
|
||||
this.instancedBackgrounds.splice(rowIndex, 1);
|
||||
this.instancedBackgrounds.push(nodesInRow);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user