|
-
Pumpkin Carving 2008
 Originally Posted by bluemagica
If it's the second, the array won't be much help, rather you will have to check all the keys pressed at the moment to determine the effect.
Not necessarily. You should know now that from your other thread that not all keyboards can support X number of key detections at once. In this case, an array would in fact help. Considering your game's frame rate of course, you could add each keystroke to an array, join that array with a null string and determine if performed a jump kick or not. Something I cooked up quick:
Code:
var keys:Array = []; // array to hold key codes
var timeout:int = 2500; // 2.5 seconds to enter combo
var jumpkick:String = "7485778075736775";
var comboTimer:Timer = new Timer(timeout, 9999);
comboTimer.addEventListener(TimerEvent.TIMER, checkCombo);
comboTimer.start();
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
function keyPressed(ke:KeyboardEvent):void {
keys.push(ke.keyCode);
}
function checkCombo(te:TimerEvent):void {
trace("Testing combos...");
if (keys.join("") == jumpkick) {
trace("\tJUMPKICK!");
keys = [];
} else {
keys = [];
}
}
Just paste it into a blank AS3 fla. Type "jumpkick" after you run the app and it will say "JUMPKICK" in the output if you entered the code correctly. I mention frame rate because you're plugging in a combo across multiple frames so if it takes you 30 frames to enter a combo and your frame rate is 31, it's going to look bad, but it's something to consider!
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|