Are there any other ways to make more than 1 kaycode instead of make a switch-case thing
Ok, bare with me, as my English may not be so good. And I'm still not a professional in AS.
I made a dancing game. A game which objects will fly up to the targets and you have to press the right keys for them. I know this is kind of the question about multiple keypress thing. But I tried look up on them. I still can't figure it out. And...because I have nearly finished my project, but those how-to-make-multiple-keys answers , I may have to recreate everything, start from 0 again.
I have made a function to put the MCs on screen and run by a class.
Then, I have made a function which detect if the target hit the right position and the right keys is pressed.
Also if the wrong keys is pressed the score will decressed.
I didnt' made only one fuction detect the keys and than say what to do .
So my question is " Are there any other ways to make more than 1 kaycode instead of make a switch-case thing, for example?"
This is some part of my code.
var p1:Number=37;// 37Left(Left)
///
function makeLvl(e:Event):void
{
if (sTime < sTempo)
{
sTime++;
}
else
{
sTime = 0;
if (SelectedLvl[sArrow] != 0)
{
var currentArrow:MovieClip;//this will hold the current arrow
if (SelectedLvl[sArrow] == 1)
{
//place a left arrow onto the stage
currentArrow = new A1();
//set the _x value of the arrow so that it is in the
//right place to touch the receptor
currentArrow.x = 120;
//set the arrow's y coordinate off of the stage
//so that the user can't see it when it appears
currentArrow.y = 400;
currentArrow.arrowCode = p1 ;
addChild(currentArrow);//add it to stage
}
////
| touchL = false; |
////
for (var i:int = 0; i<numChildren; i++)
{
var target:Object = getChildAt(i);
if (target.arrowCode != null && target.hitTestObject(mcReceptor))
{//if the object is an arrow and the receptor is touching it
if (target.arrowCode == p1)
{//if left arrow
touchL = true;
}
mcTxt.txtScore.text = 'Score: ' + score;
mcTxt.txtCombo.text = 'Combo: ' + combo;
mcTxt.txtScoreString.text = scoreString;
}
////
stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeys);
function checkKeys(e:KeyboardEvent):void
{
//if the left key is down and no left arrows are touching the receptor
if (e.keyCode == p1 && ! touchL)
{
changeHealth(-10);//make the health go down
combo = 0;
scoreString = 'Bad';
}
beginCode();
////
I've try put an Array and chage it to Number to put fit it in, but no luck.
May be I used the Array wrong?
Any ideas? Any suggestions? -- Please....
Thanks you so so much .
