hey guys, im tryin to do some scriptin for a simple game and i came across a problem, if anybody has a solution or knos where someone can give me a solution plz lemme kno....
so heres the problem...i have a stick guy for my character, i can get him to walk easily and jump if i wanted but i cant get him to run...i have just arrow keys for walking and i wanted to have arrow+shift to run...or any other simple key to go with arrow... ill post under here the general part of my script that i need help with.....
if(Key.isDown(Key.RIGHT)){
this._x += walkspeed;
this._xscale = 100;
gotoAndStop(2);
}
if(Key.isDown(Key.LEFT)){
this._x -= walkspeed;
this._xscale = -100;
gotoAndStop(2);
}
if(Key.isDown(Key.RIGHT) and (Key.isDown(Key.SHIFT))){
this._x += runspeed;
this._xscale = 100;
gotoAndPlay(3);
}
if(Key.isDown(Key.LEFT) and (Key.isDown(Key.SHIFT))){
this._x -= runspeed;
this._xscale = -100;
gotoAndPlay(3);
}
if(!Key.isDown(Key.RIGHT) and (!Key.isDown(Key.LEFT))){
gotoAndStop(1);
}
so can anyone help me?!?!?!?!? plz lemme kno what noobish thing ive done this time lolz :D
im sure itz sumthin simple...im jst a noob
HELP!!! simple actionscripting problem
Started by: yoshijumper | Replies: 5 | Views: 749
Mar 31, 2010 7:42 PM #561640
Apr 1, 2010 3:15 AM #561851
Use "else if" statements.
if(Key.isDown(Key.RIGHT) and (Key.isDown(Key.SHIFT))){
this._x += runspeed;
this._xscale = 100;
gotoAndPlay(3);
}
else if(Key.isDown(Key.RIGHT)){
this._x += walkspeed;
this._xscale = 100;
gotoAndStop(2);
}
This will first check if right and shift are both down at the same time, and if not it will check if right is pressed. If you use if statements only you may override some intended actions by your stick char.
if(Key.isDown(Key.RIGHT) and (Key.isDown(Key.SHIFT))){
this._x += runspeed;
this._xscale = 100;
gotoAndPlay(3);
}
else if(Key.isDown(Key.RIGHT)){
this._x += walkspeed;
this._xscale = 100;
gotoAndStop(2);
}
This will first check if right and shift are both down at the same time, and if not it will check if right is pressed. If you use if statements only you may override some intended actions by your stick char.
Apr 1, 2010 1:05 PM #561990
Thankx man!! really helped me, so because i only used if statements was the problem...what if i wanted a different animation to show durning like a crouch or roll, or whatever. ive never been able to play more than the one at a time, walk/run left and right...
if (Key.isDown(Key.SPACE)){
gotoAndStop(4);
crouching = true;
}
how would i get him to stay into crouch until a different button is pressed...i dont care about that as much, i just want to have an animation for running, walking, jump, crouch...i have all the ani.s but i cant get them to play..save walk and run, they play on key....
if (Key.isDown(Key.SPACE)){
gotoAndStop(4);
crouching = true;
}
how would i get him to stay into crouch until a different button is pressed...i dont care about that as much, i just want to have an animation for running, walking, jump, crouch...i have all the ani.s but i cant get them to play..save walk and run, they play on key....
Apr 3, 2010 2:09 AM #562898
....
if (Key.isDown(Key.SPACE)){
gotoAndStop(4);
crouching = true;
}
....this doesnt work by the way, i was asking if you knew how to make this work......
if (Key.isDown(Key.SPACE)){
gotoAndStop(4);
crouching = true;
}
....this doesnt work by the way, i was asking if you knew how to make this work......
Apr 4, 2010 6:13 PM #563807
wait, what's the problem? sorry your wording is kinda confusing
Apr 5, 2010 5:00 PM #564227
i can only get the running/walking to play...i cant get jumping, crouching, or any other animation to play. not just the current game im working on, but not any i have ever tried. i got walking to work by using arrow keys. then i got running to work by using an else if statement. but now i cant get any other animation to play on key...