A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Enemy Health Bars/Bosses??

  1. #1
    Junior Member
    Join Date
    Jul 2002
    Posts
    29

    Question

    Are there any tutorials or help any one can give on adding health bars to ememies? Also what is the best way to make certain enemies more powerful? i.e. inflict more damage, take less damage to make bosses for levels. I have tried to figure it out, but I have decided I really need help.

    Thanks in advance.

  2. #2
    Senior Member Genesis F5's Avatar
    Join Date
    Jan 2002
    Location
    Unallocated memory
    Posts
    1,845
    Easy as 1, 2, 3:


    Make a long horizontal bar, then turn it into a movie clip, give it the instance name "enemyhealth", and give it the actions:

    Code:
    onClipEvent(enterFrame){_x=100+(_width/2)}

    Now, in the code above, I used "100". You have to change this to the _x place of your health bar.


    Now, within your enemy/boss, put a simple hitTest, and then if it equals true, all you have to do then is put a piece of code like:

    Code:
    _root.enemyhealth._xscale-=5
    or something like that. That should take care of the health bar.


    If you want to get fancy, you can add dynamic text box health too, to get exact percentage.. like change the health bar code to this:


    Code:
    onClipEvent(enterFrame){_x=100+(_width/2);
    _root.enemyhealtht=Math.round(_xscale)+"%"}


    And remember, _root.enemyhealtht is the name that would be given to the text box for the enemy.


    As for changing power and versitility of an enemy/boss, is is as simple as changing by how much of the _xscale you reduce.




    -I hope that you find this useful




    -genesis f5



    *** sorry I had to write all of this, and I hope that you understand some of it. I would have just posted the link to a fla example, but I'm not on the one with all of my flash files .





  3. #3
    Junior Member
    Join Date
    Jul 2002
    Posts
    29

    Smile Thank you

    Thank you very much, I think I can figure it out from there. However, if you get a chance could you post the .fla? That would help me sort things out a little faster, but if not, thank you anyway.

    This board is always a lot of help, couldn't live without it.

  4. #4
    my way is very similar:

    on my monster:

    myhealth = 25;//current health
    myMaxHealth = 25;//total i can have
    healthPercent = myHealth - myMaxHealth * 100//turns into percent
    _parent.myhealthBar._width = healthPercent

    pretty easy.

    El_Y:j3

  5. #5
    Senior Member Genesis F5's Avatar
    Join Date
    Jan 2002
    Location
    Unallocated memory
    Posts
    1,845
    Posting the fla wouldn't make things go much quicker... but here it is anyways:


    To do it, just hold the left arrow (why I chose this, I have no explanation )



    http://flash__gen.tripod.com/healthbar.zip


    COPY!!/PASTE!! LINK!



    -hope this is of some use to you: Genesis f5

  6. #6
    incredibulus-actionscriptum magnetos's Avatar
    Join Date
    May 2001
    Posts
    2,160
    why do you need a movie controller for?

    i think you could put this code in one movie

    onClipEvent(enterFrame){
    if(Key.isDown(37)){_xscale-=5}_x=167.9+(_width/2);
    _root.enemyhealtht=(_xscale)+"%"}

    that should work too right?

  7. #7
    Senior Member Genesis F5's Avatar
    Join Date
    Jan 2002
    Location
    Unallocated memory
    Posts
    1,845
    Well magnetos, I was showing the controller as the enemy... how it is used remotely as if it were within the enemy/boss.


    -genesis f5



    As for your code, yeah, that would work, just remember to put a ";" between the if key, and the part that tells it to subtract _width divided by 2 from the original _x.



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