The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 3 of 3

Thread: Enemy walking / take away health & lives

  1. #1

    Enemy walking / take away health & lives

    Ok so I have a platform game and I have two types of enemies.
    Type 1 = Takes away 1 life if collides with character
    Type 2 = Takes away 5hp (health points) if collides with character.

    I know this sounds nooby but I was wondering if anyone can help me with code for the two types of enemies THEY BOTH NEED TO WALK LEFT TO RIGHT ASWELL.

    Instance names:

    Enemy type 1 = enim1
    Enemy type 2 = enim2
    Character = char

    Please help me.

  2. #2
    182
    posts
    Flash Programer guy
    Okay for hit testing and losing lives:

    _global.life=3
    _global. can be accesed on any timeline (meaning you can change the variables inside mcs)
    or
    _root.life=3
    _root.can only be acessed on the the timeline it was created on (I think)

    if you picked _global.life:

    onClipEvent(enterFrame){
    if(this.hitTest(_root.enim1)){
    _global.life--}}

    if you picked _root.life:

    onClipEvent(enterFrame){
    if(this.hitTest(_root.enim1)){
    _root.life--}}

    if you want a delay in between losing lives then do something like this:
    onClipEvent(enterFrame){
    _root.hitdelay--
    if(_root.hitdelay<=(insert number)){
    if(this.hitTest(_root.enim1)){
    _global.life--}}}

    So first _root.hitdelay is subtracted by 1 every frame. Second if the delay is less than a number then it will run the code after. Third if you hi enim1 it subtracts a life. I hope this helps =D
    I like this face

  3. #3
    ok so for the walking left and right just go into the enemy mc and create two blank keyframes make one where they are facing left and the other naturally facing right put stop(); in both frames and name the frames then simply go into the main code and put something like
    if(Key.isDown(Key.RIGHT)){
    _root.badguy.gotoAndStop('right');
    }
    and repeat for facing left.
    i believe the rest was already explained so any more questions just post em up.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012