View Full Version : Combinations in actionscript help
ryugami
January 31st, 2007, 05:35 PM
Hello all, for the past few weeks i have been putting together a 2D flash fighter for a final in my interactive communications design class and I seem to have hit a stump. The class was primarily a design class but i was more interested in the programming aspect of flash. So far actionscript has been fantastic. I just have one issue that i have been slamming my head against the monitor about for the past 6 hours.
I have scoured this and countless other forums looking for the data, Im sure its easy enough I am just missing it. I have also walked through about 9 tutorials on this site since i found these forums as well lol. An amazing resource this has been.
Thus leads me to my current predicament and why I have come to ask help. I can achieve movement and basic attack in my game just fine. What i am unable to do is create a combo.
I used a if (Key.isDown(65&& 83)) function for a dual button press combo and that works fine, but I'd like a more indepth combo capability. It also seems to break at the introduction of 3buttons.
I'd like to be able to do something along the lines of A + AB + A or something of that nature to execute a more powerful attack. I attempted nested if statements hoping it would chain down the heirarchy and trigger each as the user pressed button in sequintial order, but to no avail. I am at a total loss here.
Any help would be GREATLY appreciated.
Thanks so much..
leadbit
January 31st, 2007, 05:52 PM
ok, basically what you need is to have a kind of combo array where the sequence of keys had to be pressed is specified eg: Up + Down + kick
the folowing example illustrates three keys combo
var comboArr=new Array();
var comboC=0;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
comboC++;comboC%=3;comboArr.push(Key.getCode());
if (comboC==0)
{
trace(comboArr);comboArr=new Array();
//and here you working with combo arr determinig which actions should folow
}
};
Key.addListener(keyListener);
I`m myself wrote a fighting game, so the code is right from there - hope this would be helpful.
ryugami
January 31st, 2007, 05:59 PM
ok, basically what you need is to have a kind of combo array where the sequence of keys had to be pressed is specified eg: Up + Down + kick
the folowing example illustrates three keys combo
var comboArr=new Array();
var comboC=0;
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
comboC++;comboC%=3;comboArr.push(Key.getCode());
if (comboC==0)
{
trace(comboArr);comboArr=new Array();
//and here you working with combo arr determinig which actions should folow
}
};
Key.addListener(keyListener);
I`m myself wrote a fighting game, so the code is right from there - hope this would be helpful.
i understand somewhat, so you can store keypressed in an array using a listener, and when that combination is achieved it executes the actions designated under trace(comboArr);comboArr=new Array(); ?
the part that really confuses me is comboC++;comboC%=3;comboArr.push(Key.getCode());
im unsure where i should input what i wish the user to press in order to execute the attack.
thanks again for your prompt reply and any further help.
ryugami
January 31st, 2007, 06:13 PM
i understand somewhat, so you can store keypressed in an array using a listener, and when that combination is achieved it executes the actions designated under trace(comboArr);comboArr=new Array(); ?
the part that really confuses me is comboC++;comboC%=3;comboArr.push(Key.getCode());
im unsure where i should input what i wish the user to press in order to execute the attack.
thanks again for your prompt reply and any further help.
Actually, i figured it out. Thanks again for the function, it helped tremendously!!
One small question now, is there a way to slow down the require time for entry? so i dont have to jam on the board so rapidly? Thanks so much !
SacrificialLamb
January 31st, 2007, 10:15 PM
i think you need toy edit this
comboC%=3; (or comboC==0) :|
but i don't really understand how that code is working. i would try using setInterval, but i can't see where you would want to put that
There was also some code in the Source/Experiments that i thought of when reading this,
http://www.kirupa.com/forum/showthread.php?t=247952
http://www.kirupa.com/forum/showthread.php?t=211149
i have not used it my self but i looks a lot like an over kill
bombsledder
January 31st, 2007, 11:05 PM
http://www.kirupa.com/forum/showthread.php?t=211149
this class is by michael <-- think thats how you spell it dont feel like checking took long enough to find the thread =/
SacrificialLamb
February 1st, 2007, 12:02 AM
did you check the post above you? i found it with my first search of "Combinations key". and yes that is how you spell it
bombsledder
February 1st, 2007, 07:21 AM
oops really tired last night just read the first post and skimmed through the rest
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.