Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Help with spawning on only 1 frame

New Here ,
Mar 09, 2013 Mar 09, 2013

Hi

I'm coding in flash and I'm using class files to program but when I try to make a start menu all the ship enemy's and health bars spawn but I only want them to spawn in frame 2

Any help

Can't show any code because I'm using class files what would I show

Thanks

TOPICS
ActionScript
563
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 09, 2013 Mar 09, 2013

Can't show any code because I'm using class files what would I show

The class files?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2013 Mar 09, 2013

All of them?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 09, 2013 Mar 09, 2013

show where you call the addChild method in the Enemy class

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2013 Mar 09, 2013

here is a bit from my game class file


  function Game(){
  
   Key.initialize(stage);
   ship = new Ship();
   ship.x = 300;
   ship.y = 150;
   addChild(ship);
  
  
   enemyShipTimer = new Timer(1500);
   enemyShipTimer.addEventListener("timer", sendEnemy);
   enemyShipTimer.start();
  
   RocketShipTimer = new Timer(3000);
   RocketShipTimer.addEventListener("timer", sendEnemyRocket);
   RocketShipTimer.start();
  
   Bombtimer = new Timer(7000);
   Bombtimer.addEventListener("timer", sendBomb);
   Bombtimer.start();
  
   powerUpTimer = new Timer(10000);
   powerUpTimer.addEventListener("timer", sendPowerUp);
   powerUpTimer.start();
  
   miniBossTimer = new Timer(20000);
   miniBossTimer.addEventListener("timer", sendMiniBoss);
   miniBossTimer.start();
  
   bossCountdown = 3;
  
   scoreText = new TextField();
   scoreText.x = 290;
   scoreText.text = String(0);
   addChild(scoreText);
  
   var scoreFormat = new TextFormat("Comic Sans MS", 20, 0x000000);
   scoreText.defaultTextFormat = scoreFormat;
  
   healthMeter = new HealthMeter();
   healthMeter.x = 10;
   healthMeter.y = 10;
   addChild(healthMeter);
  
   enemyHealthMeter = new EnemyHealthMeter();
   enemyHealthMeter.x = 530;
   enemyHealthMeter.y = 10;
   addChild(enemyHealthMeter);
   enemyHealthMeter.visible = false;
  
   resetScore();
  
   gameOverMenu = new GameOverMenu();
   gameOverMenu.x = 80;
   gameOverMenu.y = 35;
   addChild(gameOverMenu);
   gameOverMenu.visible = false;
  
   gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);
  
   ship.shield.visible = false;

  }
 
  static function gameOver(){
  
   gameOverMenu.visible = true;
  
   enemyShipTimer.stop();
   miniBossTimer.stop();
   RocketShipTimer.stop();
   Bombtimer.stop();
  
  
   for(var i in EnemyShip.list){
    EnemyShip.list.kill();
   }
   for(var i in RocketShip.list){
    RocketShip.list.kill();
   }
   for(var i in Bomb.list){
    Bomb.list.kill();
   }
  
  }
 
  function newGame(e:Event){
  
   gameOverMenu.visible = false;
   ship.visible = true;
   ship.x = 300;
   ship.y = 150;
   ship.takeDamage(-ship.maxHealth);
   ship.addEventListener("enterFrame", ship.move);
   resetScore();
   enemyShipTimer.start();
   miniBossTimer.start();
   RocketShipTimer.start();
   Bombtimer.start();
  
  }
 
  function sendPowerUp(e:Event){
  
   var powerUp = new PowerUp();
   stage.addChild(powerUp);
  
  }
 
  function sendEnemy(e:Event){
  
   var enemy = new EnemyShip();
   stage.addChild(enemy);
  
  }
 
  function sendMiniBoss(e:Event){
  
   miniBossTimer.stop();
  
   if(bossCountdown == 0){
    var boss = new Boss();
    stage.addChild(boss);
    bossCountdown = 3;
   }else{
    var miniBoss = new MiniBoss();
    stage.addChild(miniBoss);
    bossCountdown -= 1;
   }
  
  
  
  }

and here is an extract from my enemy class file:

public class EnemyShip extends MovieClip{

 

 

  var speed:Number;

  static var list:Array = new Array();

  var shootTimer:Timer;

  var health:Number;

 

  function EnemyShip (){

   list.push(this);

   this.x = 700;

   this.y = Math.random()*200 + 50;

   speed = Math.random()*5 + 5;

   addEventListener("enterFrame", enterFrame);

   var interval:Number = Math.random()*700 + 1000;

   shootTimer = new Timer(interval);

   shootTimer.addEventListener("timer", shoot);

   shootTimer.start();

   health = 1;

  

  }

 

  function takeDamage(d){

  

   health -= d;

  

   if(health <= 0){

    Game.updateScore(50);

    var pd = new PointDisplay();

    pd.displayText.text = String(50);

    pd.x = this.x;

    pd.y = this.y;

    stage.addChild(pd);

    kill();   

   }

  

  }

 

  function enterFrame(e:Event){

  

   this.x -= speed;

   if(this.x < -100){

    kill();

    return;

   }

  

   if(this.hitTestObject(Game.ship)){

    kill();

    if(Game.ship.shield.visible == false){

     Game.ship.takeDamage(20);

    }

   }

  

  }

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2013 Mar 09, 2013
LATEST

Is that ok?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines