Well my concept is when you enter the scene (the frame) the enemy will slowly walk to you. You can only move along the x axis. When you press space you attack and cant move, if your touching the enemy…
Well what i’m currently doing isn’t working. I’m new to flash but i find i learn well when i fiddle with code to make it work or have help and direction. I tried the first option and it didn’t work. So here i am, after reading these forums for a few days. Problem:
enemy goes to “attack1” but freezes on first frame
character wont hitTest the enemy1 so cant attack
character:
onClipEvent (enterFrame){
{
if (Key.isDown((Key.SPACE)) and (_root.enemy1.hitTest(_x, getBounds(_root).yMax, true))){
this.gotoAndPlay (“attack”);
mySpeed = 0;
}
else mySpeed = 5;
}
}
enemy1:
onClipEvent (enterFrame)
{
moveSpeed = 3
distX = Math.ceil(_root.character._x-_root.enemy1._x);
if (distX>-100 && distX<10) {
{
this.gotoAndPlay (“attack1”);
}
}
else{
_x -= moveSpeed
this.gotoAndPlay(2)//walk action
}
if(_root.character.hitTest){
moveSpeed = 0
}
}
Please keep in mind i am new to flash. So if you do find any faults please explain why it wont work.
Thanks.