Fix: Alien moveRandomPosition
This commit is contained in:
@@ -15,7 +15,7 @@ function Alien(spaceship) {
|
||||
game.add.existing(this);
|
||||
this.moveRandomPosition();
|
||||
|
||||
this.setActive(true);
|
||||
// this.setActive(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,18 @@ Alien.prototype.moveRandomPosition = function() {
|
||||
var posX = Math.sin(radians) * radious;
|
||||
var posY = Math.cos(radians) * radious;
|
||||
|
||||
this.x = this.spaceship.x + posX;
|
||||
this.y = this.spaceship.y + posY;
|
||||
this.x = game.world.centerX + posX;
|
||||
this.y = game.world.centerY + posY;
|
||||
// this.x = this.spaceship.x + posX;
|
||||
// this.y = this.spaceship.y + posY;
|
||||
|
||||
this.angle = this.getSpriteAngle(this.angleFromAlien);
|
||||
|
||||
var alienAngle = this.getAngle(this.spaceship.x, this.spaceship.y, this.x, this.y);
|
||||
this.angle = this.getSpriteAngle(alienAngle);
|
||||
|
||||
this.angleFromAlien = alienAngle;
|
||||
|
||||
// this.angle = this.getSpriteAngle(this.angleFromAlien);
|
||||
}
|
||||
|
||||
Alien.prototype.update = function() {
|
||||
|
||||
@@ -36,7 +36,7 @@ var Game = {
|
||||
this.spaceship = new Spaceship();
|
||||
|
||||
this.aliens = [];
|
||||
for(var i = 0; i < 50; i++) {
|
||||
for(var i = 0; i < 100; i++) {
|
||||
var alien = new Alien(this.spaceship);
|
||||
this.aliens.push(alien);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user