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.
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
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.
:party: