At 5/11/07 06:18 PM, Frozen-Fire wrote:
I'll have to be honest i'm a little confused.
You could have a variable,and the variable could be named 'arrowDir' or something.
onLoad=function(){
arrowDir = dir[random(3)]; //The direction of the arrow - picks a random string/value from the 'dir' array(Use 3 because arrays are 0,1,2,3 and not 1,2,3,4)
dir:Array = new Array("left","right","up","down"); //The array of directions for the arrow
}
The code above SHOULD make an Array containing those directions,and the arrowDir will randomly select one.I don't know for sure if this works,it's just how I'd simply imagine it to be.
Next,you would have to make some codes for whichever arrow it is.
onEnterFrame = function(){
if(arrowDir == "up" && Key.isDown(Key.UP)){ //Checks if the arrowDir is up and if the key 'UP' is pressed
score+=(score value); //Increases the score by 1
unloadMovie(this); //Unloads the movie,or removing it(could also be this.play(); if you have a fancy animation on your arrow MC
}
}
The above code will just check if the direction is UP(from the previous array/variable),and if it is,then the actions will add 1 to the score and then remove the MovieClip.
To create another MovieClip for continuing this,you would use the following...
duplicate(); //You would add this to the above code that checks for key pressing.It is optional,but better to not use as much space
Ok,now duplicate(); would be a new function that you have to make.After you have declared or whatever that the Flash needs to 'duplicate();',you need to have the function.
function duplicate(){ //It's like the onEnterFrame=function,but for your own function
duplicateMovieClip(arrow,"num2"+i,i); //Duplicates the arrow MovieClip,but without actions
_root["num2"+i]._x = random(550); //Sets the new duplicate 'num2' to have a random X between 0 and 550.You can do the same for Y(with 400),assuming your stage is 550x400
arrowDir = dir[random(3)]; //Once again makes the arrow direction random from the Array 'dir',and I'm still not exactly sure about this
i++ //Makes i increase by 1
}
The above code will duplicate the 'arrow' MovieClip,rename it as num2,and make it's depth 'i'.You should add a new variable up in your onLoad code...
i = 1
After it creates a duplicate,it makes it's X (and/or Y) random.It then will make the arrow direction random.After that,it increases the i variable by 1 so the depths are not the same(if they are,this probably wouldn't work)
Now,I'd say a simple way to rotate the Arrow MC to the proper angle depending on the current arrow would to add this code to the onEnterFrame...
arrowDir == "up" ? arrow._rotation = 180 : 0;
This code just checks what direction the variable 'arrowDir' is,and then rotates the arrow MC 180 degrees.(I don't know if this would be what you put,you'd have to fool around with 0,90,180,270,and 360 to get it right)
So for that rotation code,you could add that 4 times for each different arrow direction,same with the key pressing.
Sorry if this doesn't help,it's basic.It wouldn't help with a DDR type game...that would require a bit more code,and I don't feel like going to much on about this since the array part might not even work.Good luck with whatever your doing.