Fix: group -> array, tint grey while disbled

This commit is contained in:
2018-05-12 22:31:15 +09:00
parent 5e88d510f9
commit f2cce23d9b
2 changed files with 55 additions and 26 deletions
+18 -11
View File
@@ -21,18 +21,17 @@ class Game {
// contents
this.alienGroup = game.add.group();
this.alienGroup.inputEnableChildren = true;
this.activatedAlienIndex = 0;
this.aliens = [];
for(let i = 0; i < 10; i++) {
let alien = new Alien(150 + 80 * i, 150, this.onAlienFired, this.onAlienFired);
let alien = new Alien(150 + 80 * i, 150,
() => { this.activateNextAlien(); }, // onGoOnstage
this.onAlienFired, this.onAlienEscaped);
alien.goWaitingRoom();
alien.setActive(false);
this.alienGroup.add(alien);
this.aliens.push(alien);
}
// activate first alien
// this.alienGroup[0].setActive(true);
// bottom
let screenBottom = new ScreenBottom(game);
@@ -78,15 +77,23 @@ class Game {
*/
startGame() {
console.log("startGame");
// activate first alien
this.activateNextAlien();
}
onAlienFired(sprite) {
activateNextAlien() {
if(this.activatedAlienIndex === this.aliens.length)
return;
this.aliens[this.activatedAlienIndex].setActive(true);
this.activatedAlienIndex++;
}
onAlienFired() {
console.log("onAlienFired");
sprite.goOnstage();
}
onAlienEscaped(sprite) {
onAlienEscaped() {
console.log("onAlienEscaped");
}