Scootman
October 12th, 2002, 06:45 PM
i know ive seen sample fla's on here using this... but i cant seem to find one... so ill just post again...
im makin a space ship game... and i want to be able to move my plane and fire the lasers at the same time... but the way im doing it... flash is only allowing me to press one key at a time... i know there is a function like getKey.whatever or somthin... but that makes it continuously move one direction even if i let off the key... so i changed it... i tried to make it move with easing... that didnt work as well... its sort of a mess...
basically i have an extra button on the side of the stage to hold the code for pressing keys... since i dont know how to do it within movie clips... so in the button i have:
on(keyPress"<left>"){
_root.targx -= 10;
}
on(keyPress"<right>"){
_root.targx += 10;
}
on(keyPress"<up>"){
_root.targy -= 10;
}
on(keyPress"<down>"){
_root.targy += 10;
}
on(keyPress"<space>"){
i++;
if(i==20){
i=10;//limit on lasers on the stage
}
shoot(i);
}
targx and targy are declared in the first frame of the main timeline so they can be initalized... and i attempted to make a function to move the ship... so in the frame the prototype is:
MovieClip.prototype.move = function (endx, endy, speed) {
this._x += (endx-this._x)/speed;
this._y += (endx-this._y)/speed;
};
and in the movie clip i have:
onClipEvent(enterFrame){
moveX = _root.targx;
moveY = _root.targy;
move(moveX, moveY, 5);
}
im expiramenting with new ways of doin stuff... i know functions and prototypes are good... but im still learnin how to use them... anyway... also my lasers work... but... with the limit of 10 on the levels it takes up... if i hold down the space bar they shoot so fast that they overlap... i know 10 lasers should be able to go across the screen... but they overlap and dont... is there a way to delay them so not so many are on the stage at once if i hold the button down?
i hope i explained all that stuff clear...
thanks in advance to anyone who helps me out...
im makin a space ship game... and i want to be able to move my plane and fire the lasers at the same time... but the way im doing it... flash is only allowing me to press one key at a time... i know there is a function like getKey.whatever or somthin... but that makes it continuously move one direction even if i let off the key... so i changed it... i tried to make it move with easing... that didnt work as well... its sort of a mess...
basically i have an extra button on the side of the stage to hold the code for pressing keys... since i dont know how to do it within movie clips... so in the button i have:
on(keyPress"<left>"){
_root.targx -= 10;
}
on(keyPress"<right>"){
_root.targx += 10;
}
on(keyPress"<up>"){
_root.targy -= 10;
}
on(keyPress"<down>"){
_root.targy += 10;
}
on(keyPress"<space>"){
i++;
if(i==20){
i=10;//limit on lasers on the stage
}
shoot(i);
}
targx and targy are declared in the first frame of the main timeline so they can be initalized... and i attempted to make a function to move the ship... so in the frame the prototype is:
MovieClip.prototype.move = function (endx, endy, speed) {
this._x += (endx-this._x)/speed;
this._y += (endx-this._y)/speed;
};
and in the movie clip i have:
onClipEvent(enterFrame){
moveX = _root.targx;
moveY = _root.targy;
move(moveX, moveY, 5);
}
im expiramenting with new ways of doin stuff... i know functions and prototypes are good... but im still learnin how to use them... anyway... also my lasers work... but... with the limit of 10 on the levels it takes up... if i hold down the space bar they shoot so fast that they overlap... i know 10 lasers should be able to go across the screen... but they overlap and dont... is there a way to delay them so not so many are on the stage at once if i hold the button down?
i hope i explained all that stuff clear...
thanks in advance to anyone who helps me out...