I have trouble with copying symbols, to do the same thing, in this case I need a symbol to restrict movement, to do this I created a variable for movement for each key press,
var velocity: int = 5;
var left: int = -5;
var up: int = 5;
var down: int = -5;
it worked for the first set of symbols, but when I copied the symbols and renamed them it only worked on the new symbol.
here is the coding example for the hit test I use, which works on single symbols
if (head_mc.hitTestObject(wallleft_mc)) {
left = 0;
trace("Collision detected!");
} else {
trace("No collision.");
left = -5;
}
if (head_mc.hitTestObject(wallleft2_mc)) {
left = 0;
trace("Collision detected!");
} else {
trace("No collision.");
left = -5;
}
wallleft2_mc is a copy of wallleft_mc, which I copied via pressing alt and dragging to the new location.
when I run the program, no errors appear, but the movement restriction code in the hit test codes only works on one of the symbols, not both.
how would I make it work both?
without creating new variables, which I tried to do, thanks, really appreciate the help, thanks
Aucun commentaire:
Enregistrer un commentaire