PDA

View Full Version : key problem


gamemakea
02-22-2008, 09:10 PM
im makin a game where there i a guy walking, i got his legs moving and him moving(easy). But when i move him his legs don't move until after i let go(when he stops moving his legs start).
Heres my code

onClipEvent(enterFrame){
if(Key.isDown(Key.RIGHT)){
this._x += 5;
gotoAndPlay(2)
}
if(Key.isDown(Key.LEFT)){
this._x -= 5;
gotoAndPlay(2)

}

}

Also i dont know how to but when he stops i want his legs to stop :rolleyes::mad::):cool:

CyanBlue
02-22-2008, 10:56 PM
Moving to the Gaming and Game Development forum...

Darunia9
02-25-2008, 07:19 PM
You have different movieclips for you charcter in one main movieclip, right?

If so this is how I did it

In the main movieclips actions
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop(2);
_x += 4;
}
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop(1);
_x -= 4;
}
}

The 4 being the speed it moves at and the (1) and (2) being the frames the different directions are on.

Then on each different movieclip in the main one I put this to stop it from moving it's legs when the button isn't pressed :

onClipEvent (enterFrame) {
if (!Key.isDown(key.LEFT)) {
stop();
}
else if (Key.isDown(key.LEFT)) {
play();
}
}

Hope this helps.