-
[HowTo] trigger keyboard imput command (fighting game)
Q1.
Left Left Right = function punch
Left Down Right = function fireball
how to trigger that keyboard event?
---------------------------------------
Q2.
Left > Right > Left > Right ... = true > function A
Left > Right > Right > Left ... = false > stop
Right > Left > Right > Left ... = true > function A
Right > Right > Left > Left ... = false > stop
that is:
if i continue to the pattern LRLRLRLRLRLR, the function works
if i'm not continue the pattern, say, LRLRLRRRLRRLL, the function will stop at 7
use Array?
how to do so?
thx
Last edited by yashiharu; 11-17-2005 at 10:08 AM.
-
Originally Posted by yashiharu
Q1.
Left Left Right = function punch
Left Down Right = function fireball
how to trigger that keyboard event?
You could set a variable, that will check about the user press the key that will be needed to continue in the punch-action;
(1) In the statement where you check about the user has pressed Left ( Use KeyUp here, not key down. ) you check the variable "combo". If it is 0, you set it to 1. If it is 1, you set it to 2. Else, you will set it to zero.
(2) In the statement where you check about the user has pressed Right you check the variable combo again. If it is 2, you run the function for the punch and set it to zero. Else, you just set it back to zero.
It's just the idea, I think you can't take it all by word, but tt should work if you do it this way.
And I don't get your second question, sorry...
mfg Dave
code:
#include "signature.as"
-
Senior Member
I would do it with string maybe. Whenever key is pressed its value would be added to the beginning of string. And if the length is more then you need, delete char from the end.
So, lets say the last 4 keys pressed were in order:
Up > Down > Left > Right
This would result in the string "RLDU".
Now you only need to check if that string is what you need to start the function:
if(keystring=="LLRR"){
//function A
}else if(keystring=="RLL"){
//punch
}
-
Originally Posted by davenaegeli
You could set a variable, that will check about the user press the key that will be needed to continue in the punch-action;
(1) In the statement where you check about the user has pressed Left ( Use KeyUp here, not key down. ) you check the variable "combo". If it is 0, you set it to 1. If it is 1, you set it to 2. Else, you will set it to zero.
(2) In the statement where you check about the user has pressed Right you check the variable combo again. If it is 2, you run the function for the punch and set it to zero. Else, you just set it back to zero.
It's just the idea, I think you can't take it all by word, but tt should work if you do it this way.
And I don't get your second question, sorry...
mfg Dave
thank you very much.
a very good concept for me ...
useful!
and i updated Q2
-
Originally Posted by tonypa
I would do it with string maybe. Whenever key is pressed its value would be added to the beginning of string. And if the length is more then you need, delete char from the end.
So, lets say the last 4 keys pressed were in order:
Up > Down > Left > Right
This would result in the string "RLDU".
Now you only need to check if that string is what you need to start the function:
if(keystring=="LLRR"){
//function A
}else if(keystring=="RLL"){
//punch
}
that was a wonderful method!!!
but how about the speed? will it slower?
i will try it very soon
thx
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
|