A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: My enemies attacking.

  1. #1
    Junior Member
    Join Date
    Dec 2011
    Posts
    7

    My enemies attacking.

    I want my enemies to take away from my health after a certain time its on the stage.


    So right now I have an array of enemies that pop at random.

    How do you do this? This is what I have so far:
    Actionscript Code:
    var tmr1:Timer=new Timer(2800);
            var tmr2:Timer=new Timer(5000);
    Actionscript Code:
    }
            public function targets(e:MouseEvent):void {
                iTarget=-1;
                for (i = 0; i<arTargets.length; i++) {
                    if (arTargets[i].hitTestPoint(mouseX,mouseY,true)) {
                        iTarget=i;
                    }
                }
                if (iTarget!=-1) {
                    nEnemyH-=1;
                }
                if (nEnemyH==0) {
                    removeChild(arTargets[iTarget]);
                    nEnemyH=5;
                }
            }
            function addTargets(e:TimerEvent) {
                dX=Math.random()*875;
                dY=Math.random()*400;
                t=new Enemy2();
                t.x=dX;
                t.y=dY;
                arTargets.push(t);
                addChild(t);
                tmr2.start();
                if (t.visible==true){
                    tmr2.start();
                }
                if (tmr2.currentCount%2==Uint){
                    line.x=dX
                line.y=dY
               
                    addChild(line)
                }
                if (tmr1.currentCount==30) {
                    tmr1.stop();
                }
            }


    As you can see tmr1 adds the enemies.

    tmr2 is me trying to figure out the losing HP.

  2. #2

  3. #3
    Junior Member
    Join Date
    Dec 2011
    Posts
    7
    Quote Originally Posted by whispers View Post
    **FYI......this is AS3...

    probably get better help in the AS3 forum.

    http://board.flashkit.com/board/forumdisplay.php?f=102
    Thanks, I'll post in there.

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