A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Lives countdown issue for Flash game

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    7

    Question Lives countdown issue for Flash game

    I have a simple flash game with a spaceship and enemy ships. When my player gets hit and killed, the lives text field should subtract one, and then a new ship should appear. The first time the player ship dies, this all works. But starting the second time, the lives counter starts increasing by 1 every time the player ship is hit, I have no idea why. Here's my code pertaining to the player dieing:
    Code:
    private function playerKilled(e:Event) : void {
    
            scoreBar.updateLives(-1);
        }
        private function removePlayer(e:Event) {
    
            ourShip = new Ship(stage);
            stage.addChild(ourShip);
            ourShip.x = stage.stageWidth / 2;
            ourShip.y = stage.stageHeight / 2;
        }
    
    ourShip.addEventListener("killed", playerKilled, false, 0, true);
    public function takeHit() : void {
            dispatchEvent(new Event("killed"));
            removeSelf();
    Any help or suggestions are greatly appreciated.

  2. #2
    Junior Member
    Join Date
    Oct 2012
    Posts
    7
    Just have no idea why it would start counting upwards after that first time of counting down.

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Location
    BC, Canada
    Posts
    29
    Could you post what scoreBar.updateLives() is doing? I imagine it has something to do with that.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center