Im creating a game which is using multiple keypress to play, but the problem they key are messed up. ( i cant shoot while moving the character, i can shoot but can move the character at the same time ) is it any problem to solve this? Im new to scripting so hope that someone could help out…
here is my code…
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(188)) {
player_mc.gotoAndPlay("shoot");
fireWeapon();
}
if (Key.isDown(87)) {
player_mc2.gotoAndPlay("shoot");
fireWeapon2();
}
if (Key.isDown(65)) {
if (_root.player_mc2._y<=430) {
player_mc2._y -= 0;
} else {
player_mc2._x -= 1;
player_mc2._y -= 5;
player_mc2._xscale -= 1;
player_mc2._yscale -= 1;
apdef._x += 1;
apdef._y -= 5;
apdef._xscale -= 1;
apdef._yscale -= 1;
startY2 = player_mc2._y;
}
}
if (Key.isDown(68)) {
if (_root.player_mc2._y>=670) {
player_mc2._y -= 0;
} else {
player_mc2._x += 1;
player_mc2._y += 5;
player_mc2._xscale += 1;
player_mc2._yscale += 1;
apdef._x -= 1;
apdef._y += 5;
apdef._xscale += 1;
apdef._yscale += 1;
startY2 = player_mc2._y;
}
}
}
function moveup() {
trace(player_mc._xscale)
if (_root.player_mc._y<=430) {
player_mc._y -= 0;
} else {
player_mc._x += 1;
player_mc._y -= 5;
player_mc._xscale -= 2;
player_mc._yscale -= 2;
sfdef._x -= 1;
sfdef._y -= 5;
sfdef._xscale -= 1;
sfdef._yscale -= 1;
startY = player_mc._y;
}
}
function movedown() {
trace(green._xscale*2)
if (_root.player_mc._y>=690) {
player_mc._y -= 0;
} else {
player_mc._x -= 1;
player_mc._y += 5;
player_mc._xscale += 2;
player_mc._yscale += 2;
sfdef._x += 1;
sfdef._y += 5;
sfdef._xscale += 1;
sfdef._yscale += 1;
startY = player_mc._y;
}
}
Key.addListener(keyListener);