Add: AlienGroup
This commit is contained in:
@@ -83,10 +83,10 @@ class Alien extends Phaser.Sprite {
|
||||
|
||||
goOnstage() {
|
||||
// set random position
|
||||
const SPAWN_BOX_LEFT = 50;
|
||||
const SPAWN_BOX_WIDTH = game.world.width - 100;
|
||||
const SPAWN_BOX_TOP = 250;
|
||||
const SPAWN_BOX_HEIGHT = game.world.height - 340;
|
||||
const SPAWN_BOX_LEFT = 80;
|
||||
const SPAWN_BOX_WIDTH = game.world.width - 160;
|
||||
const SPAWN_BOX_TOP = 280;
|
||||
const SPAWN_BOX_HEIGHT = game.world.height - 400;
|
||||
|
||||
this.x = SPAWN_BOX_LEFT + Math.random() * SPAWN_BOX_WIDTH;
|
||||
this.y = SPAWN_BOX_TOP + Math.random() * SPAWN_BOX_HEIGHT;
|
||||
|
||||
@@ -21,11 +21,17 @@ class Game {
|
||||
|
||||
|
||||
// contents
|
||||
let alien = new Alien(100, 150, this.onAlienFired, this.onAlienEscaped);
|
||||
alien.goWaitingRoom();
|
||||
this.alienGroup = game.add.group();
|
||||
this.alienGroup.inputEnableChildren = true;
|
||||
for(let i = 0; i < 10; i++) {
|
||||
let alien = new Alien(150 + 80 * i, 150, this.onAlienFired, this.onAlienFired);
|
||||
alien.goWaitingRoom();
|
||||
alien.setActive(false);
|
||||
this.alienGroup.add(alien);
|
||||
}
|
||||
|
||||
// activate first alien
|
||||
alien.setActive(true);
|
||||
// this.alienGroup[0].setActive(true);
|
||||
|
||||
|
||||
// bottom
|
||||
|
||||
Reference in New Issue
Block a user