View Full Version : Combination keys
Lorithon
04-21-2009, 06:34 PM
Hey i'm trying to make it so that when i press the the left mouse key with the a button this stick guy will attk while walking left and so thatwhen i press the the left mouse key with the d button this stick guy will attk while walking Right here is what i have so far (the movie clips are already in place
//if the left arrow key is down, go to frame to of this movie clip and also move left.
standStill.onEnterFrame = function() {
if(Key.isDown(68)) {
this._x+=4;
this.gotoAndPlay(3);
}
else if(Key.isDown(65)) {
this._x-=4;
this.gotoAndPlay(14);
}
else if(Key.isDown(1)) {
this.gotoAndPlay(25);
}
else if(Key.isDown(1)&&(Key.isDown(68))) {
this._x+=4;
this.gotoAndPlay(40);
}
else if(Key.isDown(1)&&(Key.isDown(65))) {
this._x-=4;
this.gotoAndPlay(55);}
//if none of the above is happening, stop on frame 1
}
scarce
04-21-2009, 06:50 PM
else if(Key.isDown(1) && Key.isDown(68)) {
this._x+=4;
this.gotoAndPlay(40);
}
else if(Key.isDown(1) && Key.isDown(65)) {
this._x-=4;
this.gotoAndPlay(55);}
//if none of the above is happening, stop on frame 1
}
Try this
Simplified version of what's going wrong:
if (a) {
// will run if a is true
} else if (b) {
// will run if a is not true and b is true
} else if ((b) && (a)) {
// will run if a is not true and b is not true, and b && a is true
// which means it will never run
}
Lorithon
04-21-2009, 07:40 PM
Hey rhh how do i make it "true" then??:confused:
scarce
04-21-2009, 08:47 PM
Hey rhh how do i make it "true" then??:confused:
if (Key.isDown(1){
//if this key is pressed down
if(Key.isDown(64){
//if this key is pressed down while the other ones pressed
//whatever actions you apply
}
}
Lorithon
04-21-2009, 09:02 PM
??? what i mean is what do i have to put instead of what i have so that this will work
the way i have it set up is that when you:
press the D key it will move the movie clip right and it will gotoAndPlay frame 3 of the standStill_mc which plays for 11 frames once it gets to the last frame it goes back to the standing still frame when he is facing right
press the A key it will move the movie clip Left and it will gotoAndPlay the frame 14 of the standStill_mc which also plays for 11 frames once it gets to the last frame it goes back to the standing still frame when he is facing Left
but i have it so that attcking and moving Left
And
attcking and moving Right
are new symbols (but still a part of standStill_mc) on different frames of standStill_mc
Is this correct or do i have to combine the two symbols to somehow play at the same time??:confused:
Why would attacking and moving right be in a movie clip called standStill_mc if you are moving to the right, rather than standing still? I'd just have all the movieclips in one batch in different frames, movingRight, standingRight, attackingStillRight, attackingMovingRight, etc etc...
Lorithon
04-21-2009, 10:02 PM
ahhh yes...... but that was the only way i found i could do that in order to make it so that he faced the same way he was moving when he stops
how would you sugest i set it up?
scarce
04-21-2009, 10:03 PM
Why would attacking and moving right be in a movie clip called standStill_mc if you are moving to the right, rather than standing still? I'd just have all the movieclips in one batch in different frames, movingRight, standingRight, attackingStillRight, attackingMovingRight, etc etc...
that's what I do, I have 1 movieclip, in that I have a frame for each action, I never animate a left stance, only facing right, to get it to work left, this_mc._xscale = -100, and vise versa to make him turn right again. Saves processing for computers
ahhh yes...... but that was the only way i found i could do that in order to make it so that he faced the same way he was moving when he stops
how would you sugest i set it up?
Oh, I see now why. I'd probably create a direction variable separate to the current frame. You can also find out the current frame from ._currentframe
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.