hello again, im having trouble with this code, hwat i want is when i press control it attacks rite? well when i wanna go up and kill a monster, i just hav to walk up to it to hurt it, how do i make it that i have to attack to hurt it, heres my line of code. PLEASE HELP
onClipEvent(load){
gravity = 0.9;
speed = 5;
yspeed = 0;
xspeed = 5;
jumping = 0;
}
onClipEvent(enterFrame){
if (Key.isDown(Key.LEFT)){
this.gotoAndStop("Walk")
this._x -= xspeed;
this._xscale = 100
}
if (Key.isDown(Key.RIGHT)){
this.gotoAndStop("Walk")
this._x += xspeed;
this._xscale = -100
}
if (Key.isDown(Key.CONTROL)){
gotoAndStop("attack")
if(this.hitTest(_root.enemy)){
_root.hp -= (random(5)+1);
}
}
if ((Key.isDown(Key.SPACE)) and (!jumping)) {
gotoAndStop("jump")
yspeed = -5;
jumping = 1;
}
yspeed += gravity;
while (_root.terrain.hitTest(_x, _y+_height/2, true)) {
_y--;
yspeed = 0;
jumping = 0;
}
if (!_root.terrain.hitTest(_x, _y+_height/2+1, true)) {
_y += yspeed;
} else {
yspeed = 0;
jumping = 0;
}
}