PDA

View Full Version : Having trouble in attacking



ar
February 21st, 2005, 07:33 PM
I want it to where when I press space a clip in a certain distance in front of me would be hit, with a simple knife thing.

This is the coding that I have for the character

onClipEvent (load) {
stop()
movespeed = 7;
stagewidth = 550;
stageheight = 400;
}


onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if(this.getBounds(_root).xMax < stagewidth) {
_x+= movespeed;
} else {
_x = stagewidth-(_width/2);
}
}
if (Key.isDown(Key.LEFT)) {
if(this.getBounds(_root).xMin > 0) {
_x-= movespeed;
} else {
_x =(_width/2);
}
}
if (Key.isDown(Key.RIGHT)) {
wasRight = true;
this.gotoAndStop(2)
} else if (Key.isDown(Key.LEFT)) {
wasRight = false;
this.gotoAndStop(3)
} else {
if(wasRight) {
gotoAndStop(1);
} else {
this.gotoAndStop(4);
}
}
}

I want an

if (Key.isDown(Key.SPACE)) {
at a close distance
if hit
then movie clip is gone


that kind of thing

can someone help me

JoMan
February 21st, 2005, 10:38 PM
Wouldn't it be easier to use the hitTest method?

kanpai

Copes
February 22nd, 2005, 11:04 AM
hmm this code looks slightly similar to my code for my main character, the problem i have with using the hit test method while attacking isnt the actual attacking. its getting the animation to stop when you release keys.. holding an attack key while moving seems to break the whole release key = stop animation, code ive got going at the moment, ive tried using the attack key by itself, and using attack && directions but neither seem to work perfectly? any ideas?